<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/256480</link>
    <title>MATLAB Central Newsreader - Background Illumination</title>
    <description>Feed for thread: Background Illumination</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Sun, 19 Jul 2009 16:36:01 -0400</pubDate>
      <title>Background Illumination</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/256480#666450</link>
      <author>Smith Kumar </author>
      <description>hello everyone, &lt;br&gt;
&lt;br&gt;
I am trying to subtract the  background illumination from an image using the following:&lt;br&gt;
&lt;br&gt;
Mean of each 16 16 small block constitute a coarse estimate of the background illumination. &lt;br&gt;
&lt;br&gt;
This estimate is  expanded to the same size as the normalizedimage by bicubic interpolation. &lt;br&gt;
&lt;br&gt;
The estimated background illumination  is subtracted from the Original image to compensate for a variety of lighting conditions.&lt;br&gt;
&lt;br&gt;
Enhance the lighting corrected image by means of histogram equalization in each 32 32 region.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
I am trying the following but my output is a completely dark image?????&lt;br&gt;
&lt;br&gt;
Many thanks in advance.  &lt;br&gt;
&lt;br&gt;
I = imread('image.jpg');&lt;br&gt;
backApprox = blkproc(I,[16,16 ],'mean(x(:))');&lt;br&gt;
backApprox = (backApprox)/255; % Convert image to double.&lt;br&gt;
figure, surf(backApprox);&lt;br&gt;
set(gca,'ydir','reverse'); % Reverse the y-axis.&lt;br&gt;
backApprox256 = imresize(backApprox, [64 512], 'bicubic');&lt;br&gt;
figure, imshow(backApprox256) % Show resized background image.&lt;br&gt;
I = im2double(I); % Convert I to storage class of double.&lt;br&gt;
I2 = I - backApprox256; % Subtract the background from I.&lt;br&gt;
I2 = max(min(I2,1),0); % Clip the pixel values to the valid range.&lt;br&gt;
figure, imshow(I2)</description>
    </item>
    <item>
      <pubDate>Sun, 19 Jul 2009 18:16:38 -0400</pubDate>
      <title>Re: Background Illumination</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/256480#666467</link>
      <author>ImageAnalyst</author>
      <description>Smith Kumar :&lt;br&gt;
You probably forgot to put [] in your imshow() function to scale your&lt;br&gt;
double to the display range.  Try this:&lt;br&gt;
clc;&lt;br&gt;
close all;&lt;br&gt;
workspace;&lt;br&gt;
I = imread('C:\Program Files\MATLAB\R2008b\toolbox\images\imdemos&lt;br&gt;
\rice.png');&lt;br&gt;
I = uint8(I);&lt;br&gt;
subplot(2,2,1);&lt;br&gt;
imshow(I);&lt;br&gt;
kernel = ones(16,16) / (16*16);&lt;br&gt;
backApprox = imfilter(I, kernel);&lt;br&gt;
subplot(2,2,2);&lt;br&gt;
imshow(backApprox, []);&lt;br&gt;
I = im2double(I); % Convert I to storage class of double.&lt;br&gt;
backApprox = im2double(backApprox); % Convert backApprox to storage&lt;br&gt;
class of double.&lt;br&gt;
I2 = I - backApprox; % Subtract the background from I.&lt;br&gt;
subplot(2,2,3);&lt;br&gt;
imshow(I2, [])&lt;br&gt;
I2(I2&amp;lt;0) = 0; % Clip the pixel values to the valid range.&lt;br&gt;
subplot(2,2,4);&lt;br&gt;
imshow(I2, [])&lt;br&gt;
set(gcf, 'Position', get(0, 'ScreenSize')); % Maximize figure.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
But you really need to decide if background subtraction is what you&lt;br&gt;
want to do.  It usually isn't, except in radiography (e.g. digital&lt;br&gt;
subtraction angiography).  Most cases should use background division.&lt;br&gt;
After all, if the corner of your image has 90% of the light incident&lt;br&gt;
on it, wouldn't you want to divide by 0.9 at those pixels?  Sure you&lt;br&gt;
would.  If you're not doing intensity analysis of the objects but are&lt;br&gt;
just doing shape analysis then subtraction can work OK to give you the&lt;br&gt;
object masks (binary image of where you objects are in your image).&lt;br&gt;
Regards,&lt;br&gt;
ImageAnalyst</description>
    </item>
    <item>
      <pubDate>Mon, 20 Jul 2009 08:30:32 -0400</pubDate>
      <title>Re: Background Illumination</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/256480#666555</link>
      <author>Ashvin</author>
      <description>On Jul 20, 4:16&#160;am, ImageAnalyst &amp;lt;imageanal...@mailinator.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; Smith Kumar :&lt;br&gt;
&amp;gt; You probably forgot to put [] in your imshow() function to scale your&lt;br&gt;
&amp;gt; double to the display range. &#160;Try this:&lt;br&gt;
&amp;gt; clc;&lt;br&gt;
&amp;gt; close all;&lt;br&gt;
&amp;gt; workspace;&lt;br&gt;
&amp;gt; I = imread('C:\Program Files\MATLAB\R2008b\toolbox\images\imdemos&lt;br&gt;
&amp;gt; \rice.png');&lt;br&gt;
&amp;gt; I = uint8(I);&lt;br&gt;
&amp;gt; subplot(2,2,1);&lt;br&gt;
&amp;gt; imshow(I);&lt;br&gt;
&amp;gt; kernel = ones(16,16) / (16*16);&lt;br&gt;
&amp;gt; backApprox = imfilter(I, kernel);&lt;br&gt;
&amp;gt; subplot(2,2,2);&lt;br&gt;
&amp;gt; imshow(backApprox, []);&lt;br&gt;
&amp;gt; I = im2double(I); % Convert I to storage class of double.&lt;br&gt;
&amp;gt; backApprox = im2double(backApprox); % Convert backApprox to storage&lt;br&gt;
&amp;gt; class of double.&lt;br&gt;
&amp;gt; I2 = I - backApprox; % Subtract the background from I.&lt;br&gt;
&amp;gt; subplot(2,2,3);&lt;br&gt;
&amp;gt; imshow(I2, [])&lt;br&gt;
&amp;gt; I2(I2&amp;lt;0) = 0; % Clip the pixel values to the valid range.&lt;br&gt;
&amp;gt; subplot(2,2,4);&lt;br&gt;
&amp;gt; imshow(I2, [])&lt;br&gt;
&amp;gt; set(gcf, 'Position', get(0, 'ScreenSize')); % Maximize figure.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; But you really need to decide if background subtraction is what you&lt;br&gt;
&amp;gt; want to do. &#160;It usually isn't, except in radiography (e.g. digital&lt;br&gt;
&amp;gt; subtraction angiography). &#160;Most cases should use background division.&lt;br&gt;
&amp;gt; After all, if the corner of your image has 90% of the light incident&lt;br&gt;
&amp;gt; on it, wouldn't you want to divide by 0.9 at those pixels? &#160;Sure you&lt;br&gt;
&amp;gt; would. &#160;If you're not doing intensity analysis of the objects but are&lt;br&gt;
&amp;gt; just doing shape analysis then subtraction can work OK to give you the&lt;br&gt;
&amp;gt; object masks (binary image of where you objects are in your image).&lt;br&gt;
&amp;gt; Regards,&lt;br&gt;
&amp;gt; ImageAnalyst&lt;br&gt;
&lt;br&gt;
Thanks ImageAnalyst ... works great....&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Now the problem I am facing is that I need to save the image and&lt;br&gt;
perform histtogram equaliuzation on it but I am getting an error on&lt;br&gt;
saving it as (I2, [])&lt;br&gt;
&lt;br&gt;
Also I need to perform histogram equalization on 32*32 blocks of the&lt;br&gt;
image.. is this the right approach or is there a better way...&lt;br&gt;
&lt;br&gt;
I3=histeq(I2, [32 32]);</description>
    </item>
    <item>
      <pubDate>Mon, 20 Jul 2009 15:11:02 -0400</pubDate>
      <title>Re: Background Illumination</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/256480#666670</link>
      <author>Smith Kumar </author>
      <description>&lt;br&gt;
I wanted to know what is the difference between&lt;br&gt;
&lt;br&gt;
imshow(I2, []) and imshow(I2)&lt;br&gt;
&lt;br&gt;
I checked out your post on Background Illumination and the image is dark when using only imshow(I2) while the image is great when using imshow(I2, [])&lt;br&gt;
&lt;br&gt;
The problem I am facing now is that I want to use the good image and perform histeq on it ....&lt;br&gt;
&lt;br&gt;
But when using&lt;br&gt;
&lt;br&gt;
I3=(I2,[]) -----Error&lt;br&gt;
&lt;br&gt;
I3=histeq(I2,[])---Error...&lt;br&gt;
&lt;br&gt;
How to pass on the good image to another variable so that I can perform other operations on it...&lt;br&gt;
&lt;br&gt;
Can you please help me... I am new to matlab....&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Thanks a lot...&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
The code I am using:&lt;br&gt;
&lt;br&gt;
I = imread('image.jpg');&lt;br&gt;
backApprox = blkproc(I,[16,16 ],'mean(x(:))');&lt;br&gt;
backApprox = (backApprox)/255; % Convert image to double.&lt;br&gt;
figure, surf(backApprox);&lt;br&gt;
set(gca,'ydir','reverse'); % Reverse the y-axis.&lt;br&gt;
backApprox256 = imresize(backApprox, [64 512], 'bicubic');&lt;br&gt;
figure, imshow(backApprox256) % Show resized background image.&lt;br&gt;
I = im2double(I); % Convert I to storage class of double.&lt;br&gt;
I2 = I - backApprox256; % Subtract the background from I.&lt;br&gt;
I2 = max(min(I2,1),0); % Clip the pixel values to the valid range.&lt;br&gt;
&lt;br&gt;
figure, imshow(I2,[]);-Good Image&lt;br&gt;
figure, imshow(I2);-Dark Image</description>
    </item>
    <item>
      <pubDate>Tue, 21 Jul 2009 04:30:19 -0400</pubDate>
      <title>Re: Background Illumination</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/256480#666824</link>
      <author>Smith Kumar </author>
      <description>&amp;gt; figure, imshow(I2,[]);-Good Image&lt;br&gt;
&amp;gt; figure, imshow(I2);-Dark Image&lt;br&gt;
&lt;br&gt;
Basically when I use imwrite((I2,[]), '1.bmp')  ----I am getting an error </description>
    </item>
    <item>
      <pubDate>Tue, 21 Jul 2009 04:42:07 -0400</pubDate>
      <title>Re: Background Illumination</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/256480#666826</link>
      <author>ImageAnalyst</author>
      <description>On Jul 21, 12:30&#160;am, &quot;Smith Kumar &quot; &amp;lt;nkm...@gmail.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; &amp;gt; figure, imshow(I2,[]);-Good Image&lt;br&gt;
&amp;gt; &amp;gt; figure, imshow(I2);-Dark Image&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Basically when I use imwrite((I2,[]), '1.bmp') &#160;----I am getting an error&lt;br&gt;
&lt;br&gt;
--------------------------------------------&lt;br&gt;
Get rid of the [].  Scale your image manually or use imadjust().&lt;br&gt;
And pick one thread and go with it.  It's ridiculous to keep 3 threads&lt;br&gt;
going on the same topic.</description>
    </item>
  </channel>
</rss>

