File Exchange

image thumbnail

AUTO ENHANCEMENT FOR IMAGES

version 1.1.0.0 (267 KB) by Divakar Roy
AUTO ENHANCEMENT FOR IMAGES to make better- looking images.

9 Downloads

Updated 28 May 2009

View License

Auto Enhancement : This Code auto enhances the images, by working on their brightness, color and contrasts. Results are shown for reference :)

Comments and Ratings (22)

hello Dibakar, i am new in this field. i cant run the program! matlab asking me put input arguments after putting it still cant see the original and enhanced image. can you help me?

DGM

Rohan: It doesn't. In any real quality sense, it destroys them by pushing data out of gamut and causing clipping.

If I recall correctly, it appears to be an attempt to do chroma stretching in YIQ. Geometrically speaking, the goal would then be to move color points radially away from the luma axis, toward the gamut extent which is a paralleliped whose diagonal is coincident with the luma axis. The problem is not independent of luma; neither is it symmetrical WRT chroma, I or Q. You either have to stay in-gamut or have some means of dealing with being out-of-gamut when you convert back to RGB, otherwise you'll be clipping. Clipping means both hue and brightness are distorted, and local contrast information is lost.

If I recall correctly, the code in this function doesn't even bother operating along the chroma axis. It merely takes the I & Q axis means, subtracts an arbitrary number, and adds that value to the axis. This completely disregards gamut extents and any saturated, bright, or dark content will be clipped. While I think there was some min/max handling at the end, I don't think it was intended for gamut constraint, but rather as some sort of of attempt at range stretching. It happens after YIQ-RGB conversion, so the clipped data is already lost.

Consider using IMCOMPARE to analyze the output of AUTOENHANCE on one of its own example images. The image shows clear loss of local contrast, and the OOG counts show a full 29% of pixels have been truncated.
http://funkyimg.com/i/2FHUZ.png

Highlighting the OOG pixels:
http://funkyimg.com/i/2FHUY.png

If all you want to do is the equivalent of slamming saturation in photoshop, you can do that using the terse syntax for the 'chroma' mode of IMLNC from the Matlab Image Manipulation Toolbox (FEX). If you don't care to do anything more analytical or nuanced, at least this keeps it from clipping:
http://funkyimg.com/i/2FHUX.png

DGM

For disclosure, I edited the code only to allow it to accept inputs and outputs from the workspace.

Rohan Shah

Can any one explain me this code how it automatically enhances images????

DGM

Re: out of gamut conditions:

This demonstrates how the problem is worse if the change in chroma is large. Dots are image pixel values after adjustment (with clamping disabled).

https://s32.postimg.org/t5e8qsytf/oog_points.png

DGM

The simple approach to operating in YIQ is going to end up with a lot of image data being pushed out of gamut. This is especially so if stretching chroma. Truncating in RGB after conversion ends up shifting clipped regions toward the primary-secondary edges of the RGB cube (since points move parallel to the RGB axes and not the axes of the luma-chroma model). It'll also result in dramatic changes in color balance.

This can be seen in the provided images, and my own tests show about 5-20% of pixels being clipped.

If it's desired to do this sort of contrast stretching in a luma-chroma model, it might be better to truncate to gamut extents while still in YIQ.

To that end, gamut boundaries can be calculated in LCH or polar luma-chroma models as demonstrated here:

http://www.mathworks.com/matlabcentral/fileexchange/57138-lch-%3C-%3E-rgb-conversion-tools/content/lchconversions/maxchroma.m

Of course, those are all cylindrical. If that's okay, something like HSY or HuSL (chroma-normalized polar variations of YPbPr or LAB/LUV) might be able to simplify things since they're normalized to the gamut boundary.

Take it with a grain of salt. I'm only commenting because I'm trying to solve these same problems. (disclosure: I uploaded maxchroma and the HSY/HuSL conversion tools)

Divakar Roy

Wan, my_limit2 and my_limit3 refer to the heuristic limits to be used to change the I and Q respectively of the NTSC converted image to "optimum" levels.

Divakar Roy

Shankar, the main aim here is to change the luminance and color profile to the "optimum" levels. To perform those, MATLAB provides built-in functions - RGB2NTSC and NTSC2RGB, so that's why NTSC system is used in the codes.

can you explain the meaning of this line in your coding:-
my_limit2=0.04;
my_limit3=-0.04;

why did there are more than one limit?
and can u explain what is this limit refer to? i mean is that refer to hue or saturation or intensity?

tq for ur response..

shankar s

pls clear my doubts. as i already asked we can use other nearest heuristic thresholds which will be applicable to this code. and one more doubt is what is purpose of converting rgb to ntsc. and why cant we use rgb to pal system... pls reply.

shankar s

can u say other nearest heuristic thersholds which can be applicable to this code

Divakar Roy

Shankar -
With heuristic I basically meant, from my experiments those values seemed to give me the "best" results. Again the "best" here is subjective to some extent. There is no other material involved.

shankar s

hi, i am new to this field. can u say what is meant by heuristic thresholds. i need materials for this program. if possible please upload it.

Divakar Roy

As said earlier, those are heuristic thresholds and nothing to do with them being positive or negative.

gomathi

what would happen if those threshold levels are changed and generally we use positive threshold levels but here u used negative thresholds. what is the use of negative threshold levels here.

Divakar Roy

gomathi -
Those are just heuristic thresholds.

gomathi

could u please tell me why u use the mylimie2=.04 and mylimit3=-.04. please reply me as soon as possible. this is my email id gomathi_24@yahoo.com. thank u

Divakar Roy

Maybe those not-brightened images won't look better if brightened. Try sending me email and then you can send me the images, will look at those. Thanks for being part of the feedback community.

Hello ,
thanks for this beautiful code,
This seems to be good.
I ahve tested it on no.of images .
I am getting mixed results.
For grayscale images out of 20 images 10 gets brightened but remaining are as it is.
what will be reason.
thanks in advance.

Divakar Roy

It's all about working on NTSC level to adjust the luminance and chrominance, and then doing contrast stretching.
Refer to my other codes, maybe that will help you. Cheers !!

Great! Giving good results and executing very fast (0.2sec per image).

Could please give us an explanation about the method. Can t understand anything from the code.

Best regards.

Updates

1.1.0.0

Small Error Fixed :)

MATLAB Release Compatibility
Created with R2007b
Compatible with any release
Platform Compatibility
Windows macOS Linux