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

Home » Public Forums » archive » Re: Image thresholding
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: Image thresholding [message #15378] Mon, 17 May 1999 00:00
David Kastrup is currently offline  David Kastrup
Messages: 33
Registered: February 1998
Member
davidf@dfanning.com (David Fanning) writes:

> David Brennan (9147261b@clinmed.gla.ac.uk) writes:
>
>> Does anyone know of a fast routine or function for searching through a
>> 3D data set and setting numbers within a predetermined range of values
>> to zero. i.e,
>>
>> the range is 5 - 10
>>
>> A data set contains [0,1,2,3,4,5,6,7,8,9]. It becomes
>> [0,1,2,3,4,0,0,0,0,0]
>>
>> This would save me a lot of time.
>
> a = [0,1,2,3,4,5,6,7,8,9]
> b = a
> b[Where(a ge 5 AND a LT 10)] = 0
> Print, b
> 0,1,2,3,4,0,0,0,0,0

You lose.

If I followup with:
IDL> a=b
IDL> b[Where(a ge 5 AND a LT 10)] = 0
% Attempt to subscript B with <LONG ( -1)> is out of range.
% Execution halted at: $MAIN$

As you can see IDL blows this handy construct if no elements meet the
conditions.

See separate post for correct solution.


--
David Kastrup Phone: +49-234-700-5570
Email: dak@neuroinformatik.ruhr-uni-bochum.de Fax: +49-234-709-4209
Institut f�r Neuroinformatik, Universit�tsstr. 150, 44780 Bochum, Germany
Re: Image thresholding [message #15379 is a reply to message #15378] Mon, 17 May 1999 00:00 Go to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
David Brennan (9147261b@clinmed.gla.ac.uk) writes:

> Does anyone know of a fast routine or function for searching through a
> 3D data set and setting numbers within a predetermined range of values
> to zero. i.e,
>
> the range is 5 - 10
>
> A data set contains [0,1,2,3,4,5,6,7,8,9]. It becomes
> [0,1,2,3,4,0,0,0,0,0]
>
> This would save me a lot of time.

a = [0,1,2,3,4,5,6,7,8,9]
b = a
b[Where(a ge 5 AND a LT 10)] = 0
Print, b
0,1,2,3,4,0,0,0,0,0

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155

[Note: This follow-up was e-mailed to the cited author.]
Re: Image thresholding [message #15381 is a reply to message #15378] Mon, 17 May 1999 00:00 Go to previous message
David Kastrup is currently offline  David Kastrup
Messages: 33
Registered: February 1998
Member
David Brennan <9147261b@clinmed.gla.ac.uk> writes:

> Does anyone know of a fast routine or function for searching through a
> 3D data set and setting numbers within a predetermined range of values
> to zero. i.e,
>
> the range is 5 - 10
>
> A data set contains [0,1,2,3,4,5,6,7,8,9]. It becomes
> [0,1,2,3,4,0,0,0,0,0]

Well, in Matlab you would write

a(find(a >= 5 & a <= 10))=0;

The equivalent in IDL would be
a[where((a ge 5) and (a le 10))] = 0

Only that this fails miserably when no members satify the condition.
A typical case of idiotic semantics of IDL core functions. So we have
to write this as:

w = where((a ge 5) and (a le 10))
if w[0] ge 0 then a[w] = 0


--
David Kastrup Phone: +49-234-700-5570
Email: dak@neuroinformatik.ruhr-uni-bochum.de Fax: +49-234-709-4209
Institut f�r Neuroinformatik, Universit�tsstr. 150, 44780 Bochum, Germany
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: special characters
Next Topic: Re: Looking for Hough and/or Radon transform code

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

Current Time: Wed Oct 08 19:34:26 PDT 2025

Total time taken to generate the page: 0.00671 seconds