Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: i would like to know about adaptive shrinkage and how it could be obtained in matlab
Date: Thu, 7 Oct 2010 16:43:05 +0000 (UTC)
Organization: anna university coimbatore
Lines: 20
Message-ID: <i8ktap$c6m$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 1286469785 12502 172.30.248.37 (7 Oct 2010 16:43:05 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 7 Oct 2010 16:43:05 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2546990
Xref: news.mathworks.com comp.soft-sys.matlab:676617

"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <hqd2j5$5vn$1@fred.mathworks.com>...
> "Susan " <Cooma_kista@yahoo.co.uk> wrote in message <hqco3h$snm$1@fred.mathworks.com>...
> > Hello there,
> > 
> > I have to admit, I am fairly new to Matlab and am running into a few problems.  I am interested in image processing and I wish to read in an image, process it grid by grid (of which size I enter) and then return the obtained values to an empty array.  I have attempted to use the 'blkproc' function and although it has been successful for calculating the std2 of my image, use of var (for variance) is not working.
> > 
> > Below you will see that to calculate the variance of each grid, I attempt to obtain the mean of the grayscale pixel values for the [MxN] grid and then apply it to each element of that grid (i.e. gridx_element, gridy_element).  
> > 
> > Any help with my code (or if I'm using blkproc incorrectly) would very much appreciated - maybe a fresh pair of eyes will do the trick!
> > 
> > Kindest regards.
> > .......
> 
>   As for using 'blkproc' why don't you just square the results you get from 'std2' to get the desired variance values.  After all, the variance is simply the square of the standard deviation.  The reason you have trouble with passing the raw 'var' to 'blkproc' is that 'var' returns a row of column variances for a block rather than a single scalar.  The same is true of 'std', which is no doubt why 'std2' was written.  You could of course write your own version of what you could call 'var2' as: "var2(A) = var(A(:));" and pass that to 'blkproc'.  It would correctly compute the desired single scalar variance for the entire A block.
> 
>   As for the code you have written, you shouldn't divide by sqrt(N*M).  That is a serious error.  You're confusing variance with standard deviation.  You should divide by M*N if you are doing population variance or by M*N-1 if it is sample variance.
> 
>   In your for-loops you haven't added the variance terms together to form a single variance for each block.  You just have the separate squared quantities occupying another block the same size as the block they were derived from.  I think you want these all summed and placed in a single entry in a smaller matrix just as you have done for the mean values.
> 
> Roger Stafford