I like "vini"'s approach, no real need to show the RGB planes.
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 Red Channel : Green channel: Blue channel: Edit 2: Defect detection using Gabor filter Its Histogram : How to calculate its appropriate threshold adaptivily.? As for inpainting in matlab, that's probably well suited for an independent question on SO. " 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. 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.
What we see as a result of lighting is an addition of specular and diffuse reflections of light (plus some emittance but its negligible here).
The specular component is the glare, on shiny surface like this apple, it is much more than the diffuse reflection (10x) This means that if you setup your lighting, gain and exposure prior to this, on a diffuse surface, you can be sure that nothing will be even close to saturated.
So using a fixed threshold is actually the preferred solution here, as long as you've proven with enough data that "no pixels not containing glare" would be above the threshold.In essence you are setting up the lighting conditions, and camera parameters such that classification of a pixel becomes trivial, in this case performed by a simple threshold, rather than a more complex machine learned function of pixels around it.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 : - Basically, the overlap ( max overlapping area ) between image #1 and #2 will be the defect.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 My opinion is that this is a machine vision problem in which you should be controlling the lighting and have a good idea of the maximum brightness of a non-glare pixel brightness in the image.Defect detection is generally a machine vision problem rather than a computer vision problem.