IOS app for programmable camera
Introduction
Programmable cameras
Our Project
Methodology
Filters using GPUImage library
Histogram and histogram equalization
Image Histograms: Histograms are graphical representations of tonal and luminance distributions in an image. Inspecting histograms of live preview in a camera can help the photographers to adjust the exposure values of their cameras. Also, the RGB histograms can be used as a guide to selectively adjust exposure for different colors. You can make sure that you are not losing details by underexposing or overexposing certain colors. That's why we incorporated the live histogram feature into our app. The GPUImage library provides APIs by which histograms of images can be extracted. We used the APIs GPUImageHistogramFilter and GPUImageHistogramGenerator to extract a histogram and plot it. After extracting the histogram image, we blend it into the live preview image using GPU blend filter. The screenshots are attached.
Histogram equalization and histogram matching: Equalizing a histogram is a technique that is used to adjust pixel intensities to enhance contrast. It's a transformation by which the image pixel intensities (often ranging from 0 - 256) are normalized and the image is transformed to an image with a linear CDF of gray levels. Since CDF can be inverse transformed, the intensities can be got back from this linearized CDF.
In a grayscale image or a monotone image, this works very well and results in better exposure of underexposed parts. Both in live images and when applied to stored images, grayscale equalization is shown to result in improving the details of the image. We could not find histogram equalization APIs in GPUIMage library. So, we used the Accelerate framework from iOS to implement histogram equalization.
Equalizing the histogram on the live image preview is useful tool for the user to adjust exposure and lighting for the scene that he is shooting.
In a color image however, this equalization needs to be repeated for the three color channels R,G and B separately. However, applying the same levels in all bins for the three channels results in color distortion and the tonal distribution of the image is messed up. This is because rarely does any image have equal intensities in all the three color channels.
We show an example of a distorted color image when the R, G and B histogram is equalized.
The same images with their RGB histograms blended over the images are as shown.