Re: Simple matrix question
- From: roberson@xxxxxxxxxxxxxxxxxx (Walter Roberson)
- Date: Fri, 19 Oct 2007 18:53:34 +0000 (UTC)
In article <ffas33$fg3$1@xxxxxxxxxxxxxxxxxx>,
Ross <ross.nospam.kozz@xxxxxxxxx> wrote:
Walter,that's exactly what I'm trying to do - form a
bounding box around a set of pixels.
Can you expound a little more on the usage of any() and find
() in this particular application.
With your specification of pixels being only 0 and 1,
if you apply any() across the row (calculating one
value per row), then you will get out a logical vector
that tells you which rows are occupied. If that vector
is V, then find(V,1) will tell you the first occupied row,
and find(V,1,'last') will tell you the last occupied row.
Repeat the process down the columns to find the first and
last occupied columns. The bounding box is then just
(firstrow, firstcolumn) to (lastrow,lastcolumn).
Note: the center of a bounding box can be very different than the
center of the object. Consider an 'L'-shaped object for example:
if the arms are equal length, then the center of the object
is the center of the joint of the two arms, but the center of
the bounding box would be outside the object.
--
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth
.
- References:
- Simple matrix question
- From: Ross
- Re: Simple matrix question
- From: Walter Roberson
- Re: Simple matrix question
- From: Ross
- Simple matrix question
- Prev by Date: highpass filter not working correctly for low freqs and high orders?
- Next by Date: Re: text in 2D plot
- Previous by thread: Re: Simple matrix question
- Next by thread: Re: Simple matrix question
- Index(es):
Relevant Pages
|