how to calculate variance of the different blocks of an image

1 view (last 30 days)
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.

Answers (2)

Sean de Wolski
Sean de Wolski on 14 Dec 2012
doc blockproc
doc var

Image Analyst
Image Analyst on 14 Dec 2012
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
student
student on 15 Dec 2012
Thanks for your response sir ,
Actually I am working on image binarization , where the threshold is decided on the basis of 1. global threshold 2.global variance as well with local threshold and local variance of window or block , where the size of local window is decided dynamically,depending upon the intensity value of pixels of the give image ie if number of black pixel is greater than white pixel the size of window will be different in comparison to case where the number of black pixel is less than white pixels. After the zoning of image ,I will proceed for local thresholding process. the whole procedure is may called adaptive thresholding. (check it out sir http://dx.doi.org/10.1016/j.patrec.2011.08.001 ), after this plz tell me how make parition and then variance calculation .
Thank You.
Image Analyst
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.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!