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 #18873 is a reply to message #18707] Mon, 07 February 2000 00:00 Go to previous message
Alex Schuster is currently offline  Alex Schuster
Messages: 124
Registered: February 1997
Senior Member
David Fanning wrote:

> Alex Schuster (alex@pet.mpin-koeln.mpg.de) writes:
>
>> Isn"t the usage of WHERE discouraged because of being slow?
>
> If it is, it's news to me. :-)

Hey! I think I read this here in this newsgroup.

>> 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 don't doubt there are speed advantages in matrix operations,
> but unless you had a huge image I doubt very much you
> would notice. And even then, the increase in speed would probably
> be more than offset by the additional memory usage.

Okay, I just tried it out. Indeed, not much of a difference, both
algorithms take about the same time. It depends on how big your index
list will get. Here's my test program:

pro test, dim

b = bindgen( dim )
starttime = systime( 1 )
index = where( b ge 200B )
if ( index[0] ne -1L ) then b[index] = 255B
print, 'Time using index list:', systime( 1 ) - starttime,$
format='(A,D8.4)'

b = bindgen( dim )
starttime = systime( 1 )
mask = b ge 100B
b = temporary( b ) * (1B-mask) + mask * 255B
print, 'Time using mask array:', systime(1) - starttime,$
format='(A,D8.4)'

end

An array of dimension 10,000,000 takes about two seconds to compute,
with the index method being slightly faster here. When lowering the
threshold, my method becomes faster.


> Plus, I don't have a clue what this code is doing when I
> read it! Simple things for simple folk, is my motto. :-)

Well, believe me or not, I think my approach _is_ simple :) Finding out
all those red values, putting them together into a list and then
assigning a new value to each pixel in this list, wow, that's a lot of
work. So I just multiply some arrays :)
Okay, I must admit, it also makes the source code look _cooler_.

> P.S. If my memory serves, Alex, aren't you the one with
> the 10 quadrillion Megs of RAM on your machine? Perhaps
> matrix operations *are* the best thing for you. :-)

Not really, I must admit. Just tested it with a size of 100,000,000, and
the mask method took 300 seconds, compared to 40 using the index list.
Hm, strange. This was a machione with 400 MB memory. On an UltraSparc
with 512 MB (not 10 quadrillion megs), it takes 32 / 37 seconds. Looks
like a constant ratio, unless swapping begins.

test, 1000000000000LLL is still running, can't say anything about that
yet... I will post the results to this newsgroup, if there still is such
a thing as newsgroups when it's finished.

Alex
--
Alex Schuster Wonko@weird.cologne.de PGP Key available
alex@pet.mpin-koeln.mpg.de
[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: Sat Oct 11 10:33:01 PDT 2025

Total time taken to generate the page: 0.56379 seconds