Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: How to obtain teh variance of an image
Date: Sat, 17 Apr 2010 20:44:05 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 27
Message-ID: <hqd6il$5r4$1@fred.mathworks.com>
References: <hqco3h$snm$1@fred.mathworks.com> <hqd2j5$5vn$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1271537045 5988 172.30.248.37 (17 Apr 2010 20:44:05 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 17 Apr 2010 20:44:05 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2120837
Xref: news.mathworks.com comp.soft-sys.matlab:627513

Hi Roger,

Indeed, I did use the blkproc function and square it to obtain the variance using the 'anonymous' form of the blkproc function.  The code I used to implement this is given by the following.  The only remaining objective I wish to accomplish is to implement a threshold variance value above which all other values are zero and I wish to assign a colour to the remaining pixels (it is a rgb to grayscale image).  I placed the 'if' loop within the following and it doesn't seem to work.

Any comments and/or suggestions I would very much appreciate!

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% variance of image grids
SV = zeros(height, width);

for y = 1:1:width
    for x = 1:1:height
        SV(x,y) = I2(x,y).^2;

%       Apply Threshold
         if SV(x,y) > (0.1*(min(min(SV))+min(min(SV))))
             SV(x,y) = 0;
        else
             SV(x,y);
         end

    end
    hold on;
end
subplot(4,1,3);
imshow(SV, []), title('Var of Image'), colormap(hot);