Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


Math Forum » Discussions » Software » comp.soft-sys.matlab

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

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Steven Lord

Posts: 17,944
Registered: 12/7/04
Re: Using loop to Cube data
Posted: Sep 16, 2013 11:25 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply



"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
To contact Technical Support use the Contact Us link on
http://www.mathworks.com




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.