Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
blockproc

Subject: blockproc

From: Naresh Pai

Date: 5 Feb, 2011 08:03:03

Message: 1 of 5

I am trying to use the blockproc function to run the bwdist function in blocks. However, I am more interested in the non-default output of bwdist, i.e the nearest-neighbor transform labels (L)

[D, L] = bwdist();

Is there a way to setup blockproc so that I can capture the second output from bwdist?

Thanks,
Naresh

Subject: blockproc

From: Donn Shull

Date: 5 Feb, 2011 15:42:04

Message: 2 of 5

"Naresh Pai" <npai@uark.edu> wrote in message <iij07n$1qe$1@fred.mathworks.com>...
> I am trying to use the blockproc function to run the bwdist function in blocks. However, I am more interested in the non-default output of bwdist, i.e the nearest-neighbor transform labels (L)
>
> [D, L] = bwdist();
>
> Is there a way to setup blockproc so that I can capture the second output from bwdist?
>
> Thanks,
> Naresh

You could write your own function that returns the value you want:

function L = mydist()
[~, L] = bwdist();
end

Hope This Helps,

Donn

Subject: blockproc

From: Naresh Pai

Date: 5 Feb, 2011 16:36:03

Message: 3 of 5

"Donn Shull" <donn.shull.no_spam@aetoolbox.com> wrote in message <iijr4c$g75$1@fred.mathworks.com>...
> "Naresh Pai" <npai@uark.edu> wrote in message <iij07n$1qe$1@fred.mathworks.com>...
> > I am trying to use the blockproc function to run the bwdist function in blocks. However, I am more interested in the non-default output of bwdist, i.e the nearest-neighbor transform labels (L)
> >
> > [D, L] = bwdist();
> >
> > Is there a way to setup blockproc so that I can capture the second output from bwdist?
> >
> > Thanks,
> > Naresh
>
> You could write your own function that returns the value you want:
>
> function L = mydist()
> [~, L] = bwdist();
> end
>
> Hope This Helps,
>
> Donn

That did work! Thanks. However, an unintended consequence was that the new labels (indices) are relative to the block sent to the function, not the original matrix. Trying to find a way to get the original indices

Subject: blockproc

From: Ashish Uthama

Date: 7 Feb, 2011 14:47:59

Message: 4 of 5

  >However, an unintended consequence was that the
> new labels (indices) are relative to the block sent to the function, not
> the original matrix. Trying to find a way to get the original indices

If your goal was to apply the bwdist per block but convert the resulting
block indices to indices of the image, you could:
* Use ind2sub to convert the linear indices into row,col indices within
the block
* Use the BLOCK_STRUCT.location (an input to your callback function) as
the additional offset to the block to compute row,col indices for the
image.
* You could optionally convert the row,col indices to the image back to
linear indices using sub2ind

Subject: blockproc

From: Naresh Pai

Date: 7 Feb, 2011 15:13:02

Message: 5 of 5

Ashish Uthama <first.last@mathworks.com> wrote in message <iip0n0$8b4$1@fred.mathworks.com>...
> >However, an unintended consequence was that the
> > new labels (indices) are relative to the block sent to the function, not
> > the original matrix. Trying to find a way to get the original indices
>
> If your goal was to apply the bwdist per block but convert the resulting
> block indices to indices of the image, you could:
> * Use ind2sub to convert the linear indices into row,col indices within
> the block
> * Use the BLOCK_STRUCT.location (an input to your callback function) as
> the additional offset to the block to compute row,col indices for the
> image.
> * You could optionally convert the row,col indices to the image back to
> linear indices using sub2ind

Ashish,

Thanks for your reply. These are great suggestions. However, I ran into additional memory-related problems even when I pass the my binary raster (7040 x 4630) through blkproc (my version does not support blockproc). I was using a 32-bit, 4 GB RAM, dual core computer. However, when I shifted to a 64-bit, bwdist ran even without blkproc. Hence, I have decided to develop this code further using a 64-bit computer itself.

Naresh

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us