Image Illumination Correction problem

5 views (last 30 days)
mustafa alnasser
mustafa alnasser on 14 Sep 2013
Dear All;
I am trying to image correction for illumination and i have tried to use the same way the matlab presented but it does not work for me, can you help me in that.
The code that I wrote:
a = imread('Slug Flow.jpg');
% Convert the image to gray level image
b= rgb2gray(a)
% Apply adaptive histogram eqaulization to enahnce the contrast of the
% image
c=adapthisteq(b);
% Illumination Correction
MN=size(c);
background = imopen(c,strel('rectangle',MN));
I2 = imsubtract(c,background);
I3= imadjust(I2);
% Convert to binary image
level = graythresh(b);
d=im2bw(I3,level);
bw = bwareaopen(d, 50);

Answers (1)

Image Analyst
Image Analyst on 14 Sep 2013
What does your image look like?
You don't want a structuring element the size of your entire image! That will give you an image out that's just a single uniform gray level. Make your structuring element smaller, like 5 or 9 pixels in diameter.
What's all the stuff about binary image for?
Do you have a "blank shot"? If so, that would be better than using adapthisteq() which is really a last resort if you don't have a background image at all and need to estimate one from the image itself, assuming that some part of the background "shows through" your sample and you know that your sample is either brighter or darker than the background.
After you have the background image what you do depends on your image. For radiology and fluorescence you subtract the background, for most other image modalities you divide by the background.
  2 Comments
mustafa alnasser
mustafa alnasser on 14 Sep 2013
Thank you very much man for your answer
But , I have tried you have said :
Make structure element smaller makes the image very dark Use Divide makes it non uniform illumination.
In fact , my image has focus light on the middle and at the side it is less , i need to get out of this problem
Best Regards
Image Analyst
Image Analyst on 15 Sep 2013
Where did you upload your image to (so I can try something)?

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!