Monday, March 31, 2008

Core Image filter for overexposed areas



Because cameras are not as smart as they should be when it comes to dynamic range, neither from a hardware nor software standpoint, and mostly because I'm not very good at using my camera, I sometimes get overexposed areas in my photos. An overexposed area is an area where pixels are all-white (i.e. lit up all the way). If the overexposed area is large enough, the photo gets an unpleasant "burned" look.

In our sample photo on the left side, the overexposed area is caused by the camera facing the light source - a common reason for overexposures as the camera's software computed the exposure based on the tulip's shaded side.


You can detect overexposed areas in a number of ways - on my Nikon D70 there's a highlights mode that blinks overexposed areas and there's a histogram on the green channel - the histogram less reliable because it does not show the red and blue channels as well so a relatively big value in the right hand side of the histogram might not necessarily mean an area has been overexposed.





Overexposed ares show up in the photo's histogram (see below for a RGB histogram - the white bar on the right side represents overexposed pixels - nearly 10% of all the photo's pixels have been overexposed).


Using Core Image filters, overexposed areas are very easy to identify.
With Core Image, using a histogram doesn't make sense - building a histogram is a computationally intensive task because it requires going through large amounts of data (a 6MB photo has, yes, 6MB of data) - it's better to write a filter that highlights the areas that have been overexposed.


Here's my (possibly naive) solution:



kernel vec4 replaceOverExposed(sampler image, __color color)
{
vec4 p = sample(image, samplerCoord(image));
float multiplier = 1;

float level = (p.r + p.g + p.b) / 3.0;

vec4 res;
res.r = level > .99 ? 1.0 : p.r;
res.g = level > .99 ? 0.0 : p.g;
res.b = level > .99 ? 0.0 : p.b;


return vec4(res.r, res.g, res.b, p.a);
}



Here's a rendering of the overexposed filter above applied on the tulip photo.
The filter has replaced all the overexposed pixels with a red pixel (p.r 1.0, p.g 0.0 and p.b 0.0).

Friday, March 28, 2008

About LoudHush 1.3.15

We're run into an incompatibility issue with version 1.3.15 that caused it not to run on non-Leopard systems (10.4, 10.3).
We have fixed this issue and are right now working to test the fixed version.

In the meantime, we've pulled 1.3.15 from the site and from the auto-updater application cast.

We will publish 1.3.16 with a correction for the problem as soon as possible.

If you've end up with a non-functioning 1.3.15, please re-download the old version from the http://www.loudhush.ro site.

Sorry for the trouble.

Thursday, March 27, 2008

New icon for LoudHush (1.3.15)



The LoudHush icon has finally been updated to Leopard requirements (512x512).

Monday, March 17, 2008

Exif Orientation

Orientation
The image orientation viewed in terms of rows and columns.
Tag = 274 (112.H)
Type = SHORT
Count = 1
Default = 1

1 = The 0th row is at the visual top of the image, and the 0th column is the visual left-hand side.
2 = The 0th row is at the visual top of the image, and the 0th column is the visual right-hand side.
3 = The 0th row is at the visual bottom of the image, and the 0th column is the visual right-hand side.
4 = The 0th row is at the visual bottom of the image, and the 0th column is the visual left-hand side.
5 = The 0th row is the visual left-hand side of the image, and the 0th column is the visual top.
6 = The 0th row is the visual right-hand side of the image, and the 0th column is the visual top.
7 = The 0th row is the visual right-hand side of the image, and the 0th column is the visual bottom.
8 = The 0th row is the visual left-hand side of the image, and the 0th column is the visual bottom.
Other = reserved


Exif2.2 Spec

Monday, March 03, 2008

Backtrace call in 10.5

backtrace() writes the function return addresses of the current call stack to the array of pointers referenced by array.

man backtrace