Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Background Illumination
Date: Sun, 19 Jul 2009 16:36:01 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 28
Message-ID: <h3vi1h$1la$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1248021361 1706 172.30.248.35 (19 Jul 2009 16:36:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sun, 19 Jul 2009 16:36:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1867706
Xref: news.mathworks.com comp.soft-sys.matlab:556632


hello everyone, 

I am trying to subtract the  background illumination from an image using the following:

Mean of each 16 16 small block constitute a coarse estimate of the background illumination. 

This estimate is  expanded to the same size as the normalizedimage by bicubic interpolation. 

The estimated background illumination  is subtracted from the Original image to compensate for a variety of lighting conditions.

Enhance the lighting corrected image by means of histogram equalization in each 32 32 region.


I am trying the following but my output is a completely dark image?????

Many thanks in advance.  

I = imread('image.jpg');
backApprox = blkproc(I,[16,16 ],'mean(x(:))');
backApprox = (backApprox)/255; % Convert image to double.
figure, surf(backApprox);
set(gca,'ydir','reverse'); % Reverse the y-axis.
backApprox256 = imresize(backApprox, [64 512], 'bicubic');
figure, imshow(backApprox256) % Show resized background image.
I = im2double(I); % Convert I to storage class of double.
I2 = I - backApprox256; % Subtract the background from I.
I2 = max(min(I2,1),0); % Clip the pixel values to the valid range.
figure, imshow(I2)