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

Home » Public Forums » archive » thresholding/color question
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: thresholding/color question [message #18872 is a reply to message #18707] Mon, 07 February 2000 00:00 Go to previous messageGo to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
Alex Schuster <alex@pet.mpin-koeln.mpg.de> writes:
> David Fanning wrote:
>
>> Then, I'd scale my image data like this:
>>
>> scaledImage = BytScl(image, Top=!D.Table_Size-4)
>>
>> I'd find the red pixels and assign them like this:
>>
>> redPixels = Where(image GT threshold, count)
>> IF count GT 0 THEN scaledImage[redPixels] = !D.Table_Size-2
>
> Isn"t the usage of WHERE discouraged because of being slow? I always use
> direct matrix operation for this, like:
>
> redmask = scaledImage GT threshold
> scaledImage = scaled_Image * (1B-redmask) + byte(!D.Table_Size-2) * redmask

I'm not sure the masking technique will always be faster. If you do
an operation count, then you can see that the masking operation costs
4*N operations, where N is the number of pixels. (operations are "GT",
"*" (twice) and "-" (once))

The WHERE technique involves somewhere between N and 2*N operations,
depending on how many pixels are above threshold (one to do the "GT"
operation, and then between 0 and N to do the scatter operation on
scaledImage). However, I will grant that the scatter operation is
probably slower than a flat-out matrix multiply.

Therefore, I would argue that for large images with few red pixels,
the WHERE operation would be superior (and as David says, use less
memory). Anybody care to bring this into the real world?

Craig

--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Cannot save MPEG
Next Topic: Q: Scientific notation in Obj. graphics

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

Current Time: Fri Oct 10 21:13:27 PDT 2025

Total time taken to generate the page: 0.80014 seconds