Re: Background Illumination
- From: ImageAnalyst <imageanalyst@xxxxxxxxxxxxxx>
- Date: Sun, 19 Jul 2009 11:16:38 -0700 (PDT)
Smith Kumar :
You probably forgot to put [] in your imshow() function to scale your
double to the display range. Try this:
clc;
close all;
workspace;
I = imread('C:\Program Files\MATLAB\R2008b\toolbox\images\imdemos
\rice.png');
I = uint8(I);
subplot(2,2,1);
imshow(I);
kernel = ones(16,16) / (16*16);
backApprox = imfilter(I, kernel);
subplot(2,2,2);
imshow(backApprox, []);
I = im2double(I); % Convert I to storage class of double.
backApprox = im2double(backApprox); % Convert backApprox to storage
class of double.
I2 = I - backApprox; % Subtract the background from I.
subplot(2,2,3);
imshow(I2, [])
I2(I2<0) = 0; % Clip the pixel values to the valid range.
subplot(2,2,4);
imshow(I2, [])
set(gcf, 'Position', get(0, 'ScreenSize')); % Maximize figure.
But you really need to decide if background subtraction is what you
want to do. It usually isn't, except in radiography (e.g. digital
subtraction angiography). Most cases should use background division.
After all, if the corner of your image has 90% of the light incident
on it, wouldn't you want to divide by 0.9 at those pixels? Sure you
would. If you're not doing intensity analysis of the objects but are
just doing shape analysis then subtraction can work OK to give you the
object masks (binary image of where you objects are in your image).
Regards,
ImageAnalyst
.
- Follow-Ups:
- Re: Background Illumination
- From: Ashvin
- Re: Background Illumination
- References:
- Background Illumination
- From: Smith Kumar
- Background Illumination
- Prev by Date: Re: Text property, 'extent', not working properly
- Next by Date: webcam color
- Previous by thread: Background Illumination
- Next by thread: Re: Background Illumination
- Index(es):
Relevant Pages
|
Loading