comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Contouring binary data
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Contouring binary data [message #2110] Thu, 02 June 1994 03:55 Go to next message
steinhh is currently offline  steinhh
Messages: 260
Registered: June 1994
Senior Member
In article <hahn.7.00131ADF@hrz.th-darmstadt.de>, hahn@hrz.th-darmstadt.de (Norbert Hahn) writes:
|> Hi all,
|>
|> I have a matrix with binary data, that is the elements contain either zero or
|> one (or some other numer). If I convert the matrix from bytarr to fltarr and
|> call contour I get some but not all contour lines. Some of them are double
|> or triple lines. When I add ,levels=[0,1] I get single lines but miss even
|> more lines.
|>
|> I guess, IDL assumes some analogue data and tries to find a "slope" or
|> a "gradient" but fails to get all non-zero elements.
|>

If the matrix is, say, 10x10, try:

IDL> contour,congrid(data,200,200),levels=[0,1]

This avoids the problem with IDL interpolating between pixels.

|> The contour lines IDL returns are rather jaggy. How to smooth these lines ?

With the above method, they aren't *smooth* (they're quite square, in fact),
but I think they should be....

Stein Vidar Haugan
Institute of Theoretical Astrophysics,
University of Oslo,
Norway
Re: Contouring binary data [message #2170 is a reply to message #2110] Fri, 03 June 1994 09:48 Go to previous message
sterner is currently offline  sterner
Messages: 106
Registered: February 1991
Senior Member
steinhh@amon.uio.no (Stein Vidar Hagfors Haugan) writes:

> In article <hahn.7.00131ADF@hrz.th-darmstadt.de>, hahn@hrz.th-darmstadt.de (Norbert Hahn) writes:
> |> Hi all,
> |>
> |>I have a matrix with binary data, that is the elements contain either zero or
> |> one (or some other numer). If I convert the matrix from bytarr to fltarr and
> |> call contour I get some but not all contour lines. Some of them are double
> |> or triple lines. When I add ,levels=[0,1] I get single lines but miss even
> |> more lines.
> |> I guess, IDL assumes some analogue data and tries to find a "slope" or
> |> a "gradient" but fails to get all non-zero elements.

> If the matrix is, say, 10x10, try:
> IDL> contour,congrid(data,200,200),levels=[0,1]
> This avoids the problem with IDL interpolating between pixels.


Here is another technique for contouring binary data.

Let b be a 2-d byte array of 0s and 1s.
then
c = smooth(b,3) ne b
gives a byte array in c with only the boundary pixels
being 1, all others are 0.

If the result is too ragged try smoothing b first. Make sure and
convert the smoothed result back to type byte. If array is a floating
point array of 0s and 1s the resulting boundary will be twice as thick.

Ray Sterner sterner@tesla.jhuapl.edu
Johns Hopkins University North latitude 39.16 degrees.
Applied Physics Laboratory West longitude 76.90 degrees.
Laurel, MD 20723-6099
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: vectorizing a correlation calculation
Next Topic: Re: Placing a base widget before it's mapped (X-windows)

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 17:14:12 PDT 2025

Total time taken to generate the page: 0.00650 seconds