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

Home » Public Forums » archive » Re: Conversion floating point to byte or integer
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: Conversion floating point to byte or integer [message #56316 is a reply to message #56315] Thu, 11 October 2007 06:20 Go to previous messageGo to previous message
beardown911 is currently offline  beardown911
Messages: 21
Registered: March 2007
Junior Member
On Oct 11, 1:08 am, "Jean H." <jghas...@DELTHIS.ucalgary.ANDTHIS.ca>
wrote:
>>> So what do you want to do with values greater than 255?
>
>>> You could do
>>> 1) compute your new image as a float,
>>> 2) scale everything down so ALL of your values are between 0 and 255 and
>>> save the image
>>> or 2) brightPixels = where(image gt 255)
>>> image[brightPixels] = 255 and save the image
>
>> Jean,
>
>> Thank you for your prompt reply and 2) is what I wanted.
>> Could I ask why this happen? Am I asking too basic question about
>> programming?
>
> So you need to scale it, not to typecast it.
> In IDL, if you typecast to byte, it does "wrap around" values, so that
> 255 is followed by 0...
> IDL> print, byte(256)
> 0
> IDL> print, byte(256+257)
> 1
>
> if you scale it using BytScl(), it takes the smallest value and assign
> it to 0, the max value to 255, and the result is a byte array
> IDL> print, bytscl([250,251])
> 0 255
>
> Jean
>
>
>
>> I casted output format to bytarr(cols, rows) to scale everything down
>> 0-255, but result was same.
>> I've read variables part in Liam's book, and tried the least
>> significant 8 bit extraction.
>> That doesn't seem to be the answer.
>
>> Well, thank you again.
>> Kim- Hide quoted text -
>
> - Show quoted text -

Jean,

Thanks a lot.

Kim
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Minor IDL code changes cause large slowdowns elsewhere in code
Next Topic: Re: Problem while deleting shape file

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

Current Time: Sat Oct 11 11:14:14 PDT 2025

Total time taken to generate the page: 1.03990 seconds