Take the 2-minute tour ×
Signal Processing Stack Exchange is a question and answer site for practitioners of the art and science of signal, image and video processing. It's 100% free, no registration required.

I have an image

enter image description here

Is there any way of removing the bright white spots ? Please help thanks

Edit:

After operating with gaussian and then displaying using imagesc get the following output which clearly shows the bright red spots How do i get rid of them

enter image description here

Red Channel :

enter image description here

Green channel:

enter image description here

Blue channel:

enter image description here

Edit 2:

Defect detection using Gabor filter

enter image description here

Its Histogram :

enter image description here

How to calculate its appropriate threshold adaptivily.?

share|improve this question
    
Is the setup of the lights known ? –  nav Jan 24 '12 at 4:44
    
No actually , is there no way of removing these to spots through filtering etc? –  vini Jan 24 '12 at 12:00
2  
In general, this is an ill-posed problem. You have too many unknowns and will have to resort to a heuristic-based solution. Good luck picking an answer. –  nav Jan 27 '12 at 6:14
add comment

3 Answers 3

up vote 12 down vote accepted
+50

Let's assume glare portions are the only saturated areas in the image. Detection can be performed by thresholding the intensity (code in Mathematica):

saturated = Binarize[ColorConvert[img, "Grayscale"], .9]

enter image description here

Then we need only to replace the portions of the image around the saturation mask (enlarging the mask is done by the morphological function Dilation). Inpainting using texture synthesis (using the function Inpaint) seems to work well in this example, though I can not test it as input to your defect-detection algorithm:

Inpaint[img, Dilation[saturated, DiskMatrix[20]]]

enter image description here

share|improve this answer
    
is there an inpaint method in matlab? –  vini Jan 26 '12 at 15:49
    
Sorry, I don't know the answer to that. –  Matthias Odisio Jan 26 '12 at 15:55
    
The defect detection is perfect however inpainting has to be implemented as there is no built in function in MATLAB –  vini Jan 26 '12 at 16:13
1  
I am glad that the answer resolved the problem. As for inpainting in matlab, that's probably well suited for an independent question on SO. See stackoverflow.com/search?q=matlab+inpainting as a start. –  Matthias Odisio Jan 26 '12 at 16:23
1  
Inpainting can be done with what is commonly known as "Poisson image blending" Tutorial here, Matlab code and examples here. –  Maurits Jan 26 '12 at 18:44
show 8 more comments

This may be a bit of a simplistic answer, but could you just threshold? e.g.:

img = imread('daRNS.png');
imflat = img; 
imflat(img>150) = 150; 
imagesc(imflat)

results in:

flattened image

It would obviously be better to select the threshold adaptively. For example you could look at the image histogram:

hist(double(img(:)),0:255)

histogram

and try to select an appropriate threshold based on that.

share|improve this answer
    
pls check my edit 2 –  vini Jan 25 '12 at 17:04
    
@vini Try look at the cut-off where 90% of the signal is explained –  tdc Jan 25 '12 at 17:20
    
i could just threshold but my ultimate goal is of defect detection.. which doesnt help in any way if i threshold it –  vini Jan 26 '12 at 12:38
3  
But your question is "How to remove the glare and brightness in an image (Image preprocessing)?" not how to detect defects, which is another (more difficult) question. @mrkulk below appears to have provided a near complete answer to that question as well below. –  tdc Jan 26 '12 at 13:53
    
yes my question is that i now how to detect defects however this glare hinders the result –  vini Jan 26 '12 at 14:15
add comment

enter image description hereWithout lighting information, it is difficult. However, if the shape of the object in the image is known, you could setup a shape template of the white glare (gaussian) and do a sliding window to find possible detection of glare (followed by color blending from adjacent area). Perceptually, we infer 3D shape from images using shading. If shape from shading is able to give the surface gradient, we could do a sliding window and check our glare template at each location.

After canny edge detection : -

enter image description here

Basically, the overlap ( max overlapping area ) between image #1 and #2 will be the defect.

share|improve this answer
    
Describing what am trying to do - I am applying a gabor filter which is mostly used for texture segmentation to find defects in fruits however the glare poses a problem as the filter displays the two white spots also as a potential defect which i do not ideally want –  vini Jan 24 '12 at 12:47
    
did you try just taking individual channels (from RGB or YUV) and just operating on them? –  mrkulk Jan 24 '12 at 13:19
    
The most glared image is the one in the green channel .. How do i operate and correct it? –  vini Jan 24 '12 at 13:35
    
I tried taking the edge image (canny) with a threshold of 0.5. As expected, I did not see the glare in the image. This should give you a strong prior for regions which do NOT contain glare. –  mrkulk Jan 24 '12 at 15:27
    
how will it help me in producing a glare free image? –  vini Jan 24 '12 at 17:51
show 3 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.