Path: news.mathworks.com!newsfeed-00.mathworks.com!solaris.cc.vt.edu!news.vt.edu!news.glorb.com!postnews.google.com!l31g2000vbp.googlegroups.com!not-for-mail
From: ImageAnalyst <imageanalyst@mailinator.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Background Illumination
Date: Sun, 19 Jul 2009 11:16:38 -0700 (PDT)
Organization: http://groups.google.com
Lines: 37
Message-ID: <f7354e0d-ded9-4533-bdbf-35c02188140f@l31g2000vbp.googlegroups.com>
References: <h3vi1h$1la$1@fred.mathworks.com>
NNTP-Posting-Host: 75.186.70.56
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Trace: posting.google.com 1248027399 12634 127.0.0.1 (19 Jul 2009 18:16:39 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Sun, 19 Jul 2009 18:16:39 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: l31g2000vbp.googlegroups.com; posting-host=75.186.70.56; 
	posting-account=0rLUzAkAAABojYSRC64DkTbtiSCX77HH
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; 
	GTB6; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 
	3.5.21022),gzip(gfe),gzip(gfe)
Xref: news.mathworks.com comp.soft-sys.matlab:556649


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