Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Using loop to Cube data
Replies: 7   Last Post: Sep 18, 2013 10:20 AM

 Messages: [ Previous | Next ]
 Steven Lord Posts: 18,038 Registered: 12/7/04
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
2-by-2 block of M stored in block_struct.data, once with the upper-right,
once with the lower-left, and once with the lower-right.

--
Steve Lord
slord@mathworks.com
http://www.mathworks.com

Date Subject Author
9/13/13 Matthew Balint
9/13/13 dpb
9/16/13 Matthew Balint
9/16/13 Steven Lord
9/17/13 Matthew Balint
9/17/13 dpb
9/18/13 Steven Lord
9/13/13 james bejon