How can I compute the mean and variance of a channel using blockproc?
Show older comments
I amy trying to compute the block-based mean and variance of each channel of an image using blockproc through block of size 8x8. After splitting the image into its channels (in the RGGB format), I used blockproc as for the red channel (I_r)
fun1 = @(block_struct) mean(block_struct.data);
mean_ch = blockproc(I_r, [8 8], fun1);
fun2 = @(block_struct) var(block_struct.data);
variance = blockproc(I_r, [8 8], fun2);
scatter(mean_ch, variance); %scatter plot of mean and variance
I get the error saying that blockproc has too many input arguments. Considering I took the syntax from the documentation, I am unable to figure what the problem is. Why does it say "too many input arguments"? Is there a different way to find mean and variance with blockproc? Any help is appreciated.
2 Comments
which -all blockproc
You should see one output that looks similar to the above, but in the directory that you installed MATLAB in to.
I suspect you will see two files instead, and that the first one is a third-party file that is interfering with your use of the Mathworks code.
Deepika Sundresh
on 11 Dec 2021
Accepted Answer
More Answers (2)
Matt J
on 10 Dec 2021
It will be more efficient if you download sepblockfun() instead,
A=double(rgbImage);
Means=sepblockfun(A,[8,8,1],'mean');
Vars=sepblockfun(A.^2,[8,8,1],'mean') - Means.^2;
1 Comment
Deepika Sundresh
on 10 Dec 2021
Deepika Sundresh
on 11 Dec 2021
0 votes
Categories
Find more on Neighborhood and Block Processing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!