Re: Simple matrix question



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
.



Relevant Pages

  • Re: Remove speckles in bilevel (bw) image
    ... pixels of B_0. ... be 'bounding box size'. ... pixel rectangle is modified by filling with black ...
    (sci.image.processing)
  • Re: barycentric coordinates for quads
    ... barycentric coordinates. ... bounding box which repeats pixel that were filled previously (by ... to fill the 2nd triangle I traversed the 1st triangle that ... splitted triangle and iterate over each pixels and decides if is ...
    (comp.graphics.algorithms)
  • Re: barycentric coordinates for quads
    ... bounding box which repeats pixel that were filled previously (by ... to fill the 2nd triangle I traversed the 1st triangle that ... What makes you think that filling using barycentric coordinates would require a bounding box? ... what makes you think barycentrics are a useful tool for a polygon into pixels? ...
    (comp.graphics.algorithms)
  • Re: stenciling out ps-invocations?
    ... Doing stencil ops inside the bounding box will potentially touch a lot of pixels that the object itself wil never touch. ...
    (microsoft.public.win32.programmer.directx.graphics)