Numerically converting the image's Cumulative Distribution Function (CDF) to another one is the main idea behind this:
Eq. 1 shows the CDF from r to z values, where the p's are the corresponding PDFs. Hence, the corresponding pixel value z is given by Eq. 2:
Figure 1. Visualization of the transformation process
Figure 2. Top to bottom: Original image, its histplot() and CDF
Figure 3. Code for generating the CDF
Fig. 2 shows the original image I've used for this activity. It is very dark, however, its histogram shows that information is stored and we're just visually handicapped to see this. From the bottom image, its CDF immediately rises, giving us the idea that most of its values are situated nearer to the dark (0) pixel values.
Figure 4. Top to bottom: Transformed image, its histplot() and CDF
I now try for a non-linear CDF. I use a cubic function (y=x^3) and get these:
Figure 5. Top to bottom: Transformed image, its histplot() and CDF
Again, the light areas of the image became more noticeable due to the new CDF. Since it is cubic, the histplot() roughly shows a quickly increasing histogram. Thus, the image became more concentrated on the range close to 1, translating to an overall increase in white-ish pixel values. Checking the generated image's CDF, we see that it is indeed cubic.
Figure 6. Code for the CDF transformations used.
To gain an insight to more advanced processes with histogram manipulation, I play around my image in GIMP. Using the Curves option, I got these:
Figure 7. Curves in GIMP 2
Trying to find a correlation between this movable line in GIMP with the CDF that I've transformed above, I get the feel that the response is somewhat flipped along that diagonal line. This may be due to GIMP treating the original image's CDF as linear, hence the diagonal line. The cubic CDF when flipped, would then be similar to the top image of Fig. 7.
Similarly, Photoshop Elements has this, too (Fig. 8). It even has presets.
Figure 8. Photoshop Elements 6.0 curves interface
For me, this was a messy activity in terms of coding the transform. Psh.
Self-Assessment: 9/10
Acknowledgements: T.J. Abregana, T. Tuballa and K. Cheng for their help in coding.
No comments:
Post a Comment