Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.



Re: Using loop to Cube data
Posted:
Sep 16, 2013 11:25 AM


"Matthew Balint" <mjbalint2@gmail.com> wrote in message news:l172an$2gh$1@newscl01ah.mathworks.com... > dpb <none@non.net> wrote in message <l0vs32$ft4$1@speranza.aioe.org>... >> On 9/13/2013 3:03 PM, Matthew Balint wrote:
*snip*
> I tried to use the blockprock function, and I don't understand the 'fun' > function handle.
It is the function that you want to be applied to each block.
> It instructed me to use 'block_struct' and 'block_struct.data' and I have > no idea what those are or how to use them.
See the Definitions section of the BLOCKPROC documentation page for information about the fields contained in the block_struct struct array.
http://www.mathworks.com/help/images/ref/blockproc.html
My guess is that BLOCKPROC passes that structure instead of just the specified piece of your matrix into the function because for image processing applications that extra information may be useful. The data field of that struct array contains just the specified piece of your matrix.
> My array is simply numeric and I thought block_struct.data was an array > that contained multiple values, not just numeric values?
Take a look at this example:
>> M = reshape(1:16, [4 4]); >> blockproc(M, [2 2], @(block_struct) mean(block_struct.data(:)))
BLOCKPROC will call this function four times: once with the upper left 2by2 block of M stored in block_struct.data, once with the upperright, once with the lowerleft, and once with the lowerright.
 Steve Lord slord@mathworks.com To contact Technical Support use the Contact Us link on http://www.mathworks.com



