Re: illumination elimination
- From: "Dave Robinson" <dave.robinson@xxxxxxxxxxxxx>
- Date: Sun, 20 Nov 2005 10:15:50 -0500
Thom J. wrote:
>
>
> Thom J. wrote:
>>
>>
>> Hi,
>>
>> I am trying to extract an image of an object from an image
>> containing
>> the object and different levels of illumination. Can you please
>> tell
>> me which MATLAB functions I need to use. Thanks.
>
> Just to clarify on what I am looking for. I have an image
> containing
> an object, but the background is of varying intensity. I need to
> see
> the edges of the object clearly. Which functions can I use to
> achieve
> this. Thanks.
Here is the basis of a technique, which will either work brilliantly,
else not work at all, depending on the actual image in question.
1) If it is a colour image separate the colour information from the
intensity information by converting to something like HSV colour
space. Use only the V plane, leave the others strictly alone.
2) The theory - Each pixel in your V plane or monochrome image
consists of two components, one is the pixels reflectance, and the
other is the illumination falling on the pixel. What you actual
measure is the product of the two.
Image(x,y) = Reflectance(x,y).*Intensity(x,y)
3) In natural images the illumination is NORMALLY a very low speed
function. That is to say it only changes smoothly across the image.
Whereas the reflectance matrix will contain high speed changes, which
gives rise to the detail within your image.
4) Unfortunately DSP is only well equipped to deal with linear
combination of signals, and cannot cope with a multiplication of
signals in this fashion.
5) Undertake a logarithm of your image. That is to say form another
image, the same size as your original one, whose pixel intensities
are equal to the log of your original pixel intensities. The base of
the logarithm is irrelevant providing you are consistent throughout.
6) This converts the the Image structure we showed above into
something like
LImage(x,y) = log(Reflectance(x,y)) + log(Illumination(x,y))
7) Now we see that, NORMALLY the log(Illumination) function is mainly
low frequency stuff, whereas the log(Reflectance) component is high
frequency stuff, so we can have a go at separating them by simply
high pass filtering the log image. This can be done relatively easily
in the frequency domain.
8) Take your log image, and apply the fft() function to it, apply the
fftshift function to get DC in the centre.
9) Go into a paint package, and on a pure white image, draw a black
circle, whose origin is on the centre of the image. This is your
filter. The bigger the radius of the circle, the higher the frequency
band that gets stopped.
10) Read your filter into Matlab using imread(), then multiply your
Fourier transform image by your filter. pixel by pixel (.*).
11) Apply ifftshift() to the product, and apply the ifft() to the
result. Any residual complex components you have left, you can remove
by either finding the abs() of the result, else real() of the result.
12) Now you have deemphasised the illumination on your log image, all
you now need to do is to convert it back to linear space, which you
do by finding the antilog of each pixel using the exponentiation
operator, to whatever base you originally selected for your log
operator.
13) If you started life with a colour image reform your HSV structure
by replacing the original V plane with the one you have just
computed; if it was monochrome to start with you have finished this
stage of the processing.
14) Visually compare the original image with your processed image,
and adjust the diameter of your filter circle until you get an image
from which you can extract your edges.
Two things you must remember is that when you filter out the DC
component, sitting right in the centre of your filter, your resulting
pixels become bipolar, remember to offset the result of the filtering
by the minimum value of the filtered result, in order to maintain a
sensible image structure (Images don't have negative pixel values).
Also be careful when you find the original log image, when converting
true black pixels as log(0) is a meaningless number. I usually add a
very small number to any black pixel, to circumvent this problem
.
- References:
- illumination elimination
- From: Thom J.
- Re: illumination elimination
- From: Thom J.
- illumination elimination
- Prev by Date: Re: Intresting code...
- Next by Date: cone
- Previous by thread: Re: illumination elimination
- Next by thread: Re: MAKE MONEY QUICK, EASY ,AND LEGALLY !!!
- Index(es):
Relevant Pages
|
Loading