One of the todo items for the road to beta is an automatic image level adjuster. Put simply, it’s the easy button for histogram manipulation. Advanced graphics nerds know how to use curves to modify an image’s histogram. Everyone else just hits “auto adjust” and BOOYA…the image magically looks better (sometimes).
For the uninitiated, histograms are graphs that show how colors are distributed throughout an image. Each element in a color space has 255 possible values. Knowing that, we design our histogram to have 255 possible x-axis values. What we do is inspect each pixel’s color, and whatever value it is (from 0 – 255) we increment that point in the graph by one unit.
In the upper right hand corner you’ll see the newly minted histogram window for PhotoMonkee. The peaks on the left side of the graph show that there are a lot of red, green and blue pixels with values between 0 and 75 with not many in the middle to higher range. RGB values (that’s short for red, green and blue in the nerd circles) are cool to see on a graph but what we’re really after is a completely different color space called HSL or Hue, Saturation and Lightness.
Here’s the histogram in HSL space for the cork image on the left. On the right is the image of just the Lightness parameter.
What we want to do is get the lightness component to use more of its available spectrum. You can see on the very right edge of the graph there are no values being used. That means we can “stretch” the graph out to use the entire spread of values. After “stretching” the graph we then go back and map the lightness value of each pixel to its new spot on the graph. The result looks like so:
If you compare the two images you’ll note that the overall brightness of the resultant image has been increase but the color values have remained relatively unchanged. There is still plenty of tweaking to be done but this is a fantastic start.
To calculate the RGB and HSL histograms for a 1920×1080 image takes roughly 90 milliseconds. Stunning when you consider converting from RGB to HSL color space for every pixel isn’t exactly a cheap conversion. Also, my way of incrementing the ‘buckets’ is ridiculously slow and contentious since I’m using OpenCL’s atomic_inc() extension. I’ll have to revisit this later for further optimization.
Viva Le Histogram!
During the initial development of PhotoMonkee I assumed that having a global foreground and background color was the best way to manage colors for the tools. Each tool would be able to ask the global palette manager “what is the current foreground/background color” and use that in whatever operation it needed. Here’s the problem: most tools don’t use a background color and the tools that do use it aren’t very clear as to what they’re using it for.
So, rather than having a single foreground/background color I’m throwing them both out the window and allowing each tool to manage the colors that it needs individually. That means the painting tool’s current color will be completely separate from the fill tool’s current color. If you switch between the two, they will each remember their color independently.
When a tool is activated, by clicking on it in the tool box, one or more swatches will be displayed in the global tool bar. For example, selecting the “rounded rectangle” tool will display two swatches, one for the fill color and one for the border color. The user can click on each swatch which will activate the (newly redesigned!) palette dialog box. Changing the color in the palette dialog box, or dragging a pre-defined swatch from the palette onto the tool’s swatch will change the color for the tool.
It all sounds terribly confusing but rest assured, the workflow is very intuitive and you won’t miss seeing this old relic in your toolbar:
I just realized tonight while talking to a friend that I hadn’t actually given a high level overview of what PhotoMonkee actually is!
In short: PhotoMonkee is an image editing application for the PC, Mac and Linux. It has all the basic functionality you’d expect from an image editor along with a plugin architecture to allow for third party options for image filtering. Let’s go through a quick rundown of what’s been coded up so far.
There is a layering system, complete with per-layer styles. Image tools available include:
- Layer/Selection movement
- Text Entry and Editing with system font support
- Selection Tools (Rectangle, Ellipse, Magic Wand)
- Paint Bucket Fill
- Line Drawing
- Rectangle, Rounded Rectangle and Ellipse drawing
- Color Selector
Canvas re-sizing and cropping is also available via the menu.
Supported file formats include:
The to-do list contains many items that will be implemented over the next month and beyond but as you can see, PhotoMonkee is aiming to be an easy to use image editor at a reasonable price and supported by a small team focused on our community.