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 #56322 is a reply to message #56321] Wed, 10 October 2007 21:20 Go to previous messageGo to previous message
beardown911 is currently offline  beardown911
Messages: 21
Registered: March 2007
Junior Member
On Oct 10, 6:44 pm, "Jean H." <jghas...@DELTHIS.ucalgary.ANDTHIS.ca>
wrote:
> go cats wrote:
>> Hello Gurus,
>
>> I've been trying to write a code to correct imagery data. Original
>> imagery data format is byte format.
>> Steps for the processing includes reading the original data,
>> subtracting dark current, and multiplying calibration coefficients and
>> saving the results. The two values; dark current and calibration
>> coefficients are given by arrays with floationg point format.
>> The code seemes to work without any problem. But in the resulting
>> image saved in binary format , numbers higher than 255 store only
>> remants of what is subtracted from 256. The reason I want to convert
>> to byte is to save some disk space. In the image saved as floating
>> point format pixel values look ok.
>> Could you give some advice what part of program I have to look at? and
>> what causes this problem?
>
>> Thank you in advance,
>> Kim
>
> 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- Hide quoted text -
>
> - Show quoted text -

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?
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
[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: Sun Oct 12 01:20:20 PDT 2025

Total time taken to generate the page: 1.83957 seconds