how to calculate variance of the different blocks of an image
Show older comments
respected sir / madam
i have a question that how to make partition of an image in to blocks of the size decided dynamically means the size may vary dependent on some condition(like a dynamic window ).
i am trying mat2cell function but because of the size(height , width ) may come in fraction too, it doesn't work .
eg. image size is (295x500), if the block size comes, on sm condition, 9.83 x 12.5 .In this case if we use round , ceil or floor function the whole pixel will not be cover and the function mat2cell will give error
??? Error using ==> mat2cell at 116 Input arguments, D1 through D2, must sum to each dimension of the input matrix size, [295 500].
kindly guide me some guidance to overcome this problem.
thanks .
Actually i want to make block on matrix and after that i want to calculate the variance for each block.
1 Comment
Walter Roberson
on 14 Dec 2012
What do your requirements say should happen for the partial blocks?
Answers (2)
Sean de Wolski
on 14 Dec 2012
doc blockproc
doc var
Image Analyst
on 14 Dec 2012
0 votes
As I understand it, blockproc works only with uniformly sized blocks, not blocks that change their size on a location-by-location basis. Perhaps you could pass in the largest possible block and the information for what size to reduce the block to and then the function could crop down the block and use just a smaller chunk of it. Would that work for you? What criteria do you have that makes the block change size from pixel to pixel? Does the block size at each location depend on the intensity at that location or something?
6 Comments
Walter Roberson
on 14 Dec 2012
I still can't figure out how you can have a block with .83 of a pixel in it?
Image Analyst
on 14 Dec 2012
Yeah - neither do I. Perhaps he wants to "feather" the edge to anti-alias the window like Photoshop does???? Though it seems like some function generates the window sizes for him and he's okay with rounding it to integer values. Though I'm not sure why he says " if we use round , ceil or floor function the whole pixel will not be cover" because as I see it if you use those functions you MUST cover the whole pixel since it gets rid of fractional pixels. Maybe he means that the whole image won't be covered because the block at the edge of the image does not perfectly fit inside the image. Like you've covered the image except for the last two columns but this function tells you that you're supposed to have a window 3.5 wide, so even if you go to 3 or 4 wide, it's still outside the image. But this is just normal edge/boundary condition stuff like you do with any window scanning operation.
Walter Roberson
on 15 Dec 2012
I'm quite tempted to think that when he says 9.83 x 12.5 that student is talking about inches, as A4 paper is formally 9.84 inches x 13.90 inches.
Image Analyst
on 15 Dec 2012
Why would paper size have anything to do with calculating variance? and what does " image size is (295x500), if the block size comes, on sm condition, 9.83 x 12.5" mean? I have no idea what an "sm condition" is. Any idea why he wants the window size to vary dynamically across the image? I've heard of it being done (e.g. http://viola.usc.edu/Research/Tanaphol_TThaipanich_ICCE10.pdf) but I think the algorithms are a bit over his head.
student
on 15 Dec 2012
Image Analyst
on 15 Dec 2012
Edited: Image Analyst
on 15 Dec 2012
I think this section of the FAQ applies here: http://matlab.wikia.com/wiki/FAQ?&cb=5688#Can_you_program_up_the_algorithm_in_this_article_for_me_and_explain_it_to_me.3F, not to mention the fact that I don't want to pay $31.50 to read the article. Good luck with it though. It looks like it might be a useful algorithm.
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!