Macro command setPixel(x, y, p)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Macro command setPixel(x, y, p)

Divakar Ramachandran-2
Greetings to all,

I have an output from a program in the form of 256x256 floating point
numbers approximately in the range 10^-5 to 10^-3 which I need to
display as an image. To process some header stuff, reading the 256x256
values and write out a TIFF file, I have written a macro script in
ImageJ. In this connection I have a question about setPixel:

I have created a new image stack using
"newImage(imiFile,"16-bit",nX,nY,datFiles.length);". The individual row
data are obtained using "rowData = split(lineData[8+j],"   ");" based on
the format in which the data is output by the programme. Subsequently,
the pixel data is set using "pxy = parseFloat(rowData[k]); // print(j,
k, pxy); setPixel(j, k, pxy);". The (now) commented out print command
verified that the correct floating point values are being detected by
parseFloat. However, the saved TIFF shows all pixel values as zero.

My question is, in writing a 16-bit TIFF, should I be scaling the
floating point data to int between 0 and 2^16? Or between 0 and 2^8 if I
change this to 8-bit? Is there a way to preserve the numerical values of
the simulation, and yet visualise as an image with contrast stretched to
16-bit or 8-bit precision?

Thanks,
Div.

--
*Dr. Divakar R.*
_Anupuram, TN 603127, INDIA._

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Macro command setPixel(x, y, p)

Michael Entrup
Hi Divakar,

the easiest solution would be to use 32-bit instead of 16-bit. A 16-bit
image can only handle integer values (try 'Process > Math > Set...' with
'0.00001'). If you want to enter something like your numbers directly,
you have to switch to a floating point image type.

Best regards
Michael


Am 29.03.2015 um 20:26 schrieb Divakar Ramachandran:

> Greetings to all,
>
> I have an output from a program in the form of 256x256 floating point
> numbers approximately in the range 10^-5 to 10^-3 which I need to
> display as an image. To process some header stuff, reading the 256x256
> values and write out a TIFF file, I have written a macro script in
> ImageJ. In this connection I have a question about setPixel:
>
> I have created a new image stack using
> "newImage(imiFile,"16-bit",nX,nY,datFiles.length);". The individual row
> data are obtained using "rowData = split(lineData[8+j],"   ");" based on
> the format in which the data is output by the programme. Subsequently,
> the pixel data is set using "pxy = parseFloat(rowData[k]); // print(j,
> k, pxy); setPixel(j, k, pxy);". The (now) commented out print command
> verified that the correct floating point values are being detected by
> parseFloat. However, the saved TIFF shows all pixel values as zero.
>
> My question is, in writing a 16-bit TIFF, should I be scaling the
> floating point data to int between 0 and 2^16? Or between 0 and 2^8 if I
> change this to 8-bit? Is there a way to preserve the numerical values of
> the simulation, and yet visualise as an image with contrast stretched to
> 16-bit or 8-bit precision?
>
> Thanks,
> Div.
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Macro command setPixel(x, y, p)

Divakar Ramachandran-2
Thanks, Michael. Changing over to 32-bit worked!

With Regards,
Divakar



Michael Entrup wrote on Monday 30 March 2015 01:53 PM:

> Hi Divakar,
>
> the easiest solution would be to use 32-bit instead of 16-bit. A
> 16-bit image can only handle integer values (try 'Process > Math >
> Set...' with '0.00001'). If you want to enter something like your
> numbers directly, you have to switch to a floating point image type.
>
> Best regards
> Michael
>
>
> Am 29.03.2015 um 20:26 schrieb Divakar Ramachandran:
>> Greetings to all,
>>
>> I have an output from a program in the form of 256x256 floating point
>> numbers approximately in the range 10^-5 to 10^-3 which I need to
>> display as an image. To process some header stuff, reading the 256x256
>> values and write out a TIFF file, I have written a macro script in
>> ImageJ. In this connection I have a question about setPixel:
>>
>> I have created a new image stack using
>> "newImage(imiFile,"16-bit",nX,nY,datFiles.length);". The individual row
>> data are obtained using "rowData = split(lineData[8+j],"   ");" based on
>> the format in which the data is output by the programme. Subsequently,
>> the pixel data is set using "pxy = parseFloat(rowData[k]); // print(j,
>> k, pxy); setPixel(j, k, pxy);". The (now) commented out print command
>> verified that the correct floating point values are being detected by
>> parseFloat. However, the saved TIFF shows all pixel values as zero.
>>
>> My question is, in writing a 16-bit TIFF, should I be scaling the
>> floating point data to int between 0 and 2^16? Or between 0 and 2^8 if I
>> change this to 8-bit? Is there a way to preserve the numerical values of
>> the simulation, and yet visualise as an image with contrast stretched to
>> 16-bit or 8-bit precision?
>>
>> Thanks,
>> Div.
>>
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html


--
*Dr. Divakar R.*
_Anupuram, TN 603127, INDIA._

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html