intensity at each pixel in CSV format to open as greyscale image in imageJ

classic Classic list List threaded Threaded
17 messages Options
Reply | Threaded
Open this post in threaded view
|

intensity at each pixel in CSV format to open as greyscale image in imageJ

kumard
I have Optical coherence tomography (OCT) scan data in the form of intensity
value for each pixel in an array of 309 x 826. I want to convert that data
in the form of a greyscale image (min intensity: -22.3516 and Max intensity:
52.6367), say <0 dark grey but 0-10, 10-20,30-40 and >40 in the order of
lighter grey to white and quantify each increase in the form of % and
pixels. Thanks in advance for answering and helping out.



--
Sent from: http://imagej.1557.x6.nabble.com/

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

Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

CARL Philippe (LBP)
Dear Kumar,
What you are looking for can easily be done by means of a small macro.
I would create a 309 x 826 pixels 8 bit picture setting by means of the setPixel method the lowest of your value to 0 and the highest to 255.
And to open the .csv file use File.openAsString on which result you apply the split method to extract the data for each pixel.
My best regards,
Philippe


Philippe CARL
Laboratoire de Bioimagerie et Pathologies
UMR 7021 CNRS - Université de Strasbourg
Faculté de Pharmacie
74 route du Rhin
67401 ILLKIRCH
Tel : +33(0)3 68 85 41 84

----- Mail original -----
De: "kumard" <[hidden email]>
À: "imagej" <[hidden email]>
Envoyé: Vendredi 8 Novembre 2019 22:25:05
Objet: intensity at each pixel in CSV format to open as greyscale image in imageJ

I have Optical coherence tomography (OCT) scan data in the form of intensity
value for each pixel in an array of 309 x 826. I want to convert that data
in the form of a greyscale image (min intensity: -22.3516 and Max intensity:
52.6367), say <0 dark grey but 0-10, 10-20,30-40 and >40 in the order of
lighter grey to white and quantify each increase in the form of % and
pixels. Thanks in advance for answering and helping out.



--
Sent from: http://imagej.1557.x6.nabble.com/

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

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

Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Kenneth R Sloan-2
In reply to this post by kumard
I would do this with Java, but I'll take a stab at this.

First - I believe you will need to convert from float to 8-bit integer.
Set the min/max to something standard.  Based on your numbers, I would
set min to -127.0 and max to +128.0

Now, convert to 8-bit, which should map -127.0 -> 0 and +128.0->255.

An original value of x would map to floor(x+127.0).

Next, use the LUT tools to create a custom Lookup Table, with breakpoints
at 0.0 -> 127, 10.0 -> 137, 20.0 -> 147, 30.0 -> 157, and 40.0 -> 167.

Now you have a displayed image with 6 different gray levels.

I'll let someone else explain how to count the number of pixels in each range using
standard ImageJ interactive tools - as I say, I would just write a Java plugin to do it.
I thought that "Apply LUT" would be the right tool - but it complains to me and I can't
make the error message disappear, so I gave up.

What follows is an unnecessary rant - feel free to ignore it:

============================================================================================
In my opinion, anyone doing serious image processing should have a simple prototype
program (it could be a macro, or - my preference - a full Java program) that steps
through every pixel in an image and "does something" with that pixel.

Once you have this program, questions like the one posed by the OP can be answered by
saying "convert your specifications into code for the method 'doSomethingToThisPixel()' and create
a new tool that does EXACTLY what you want."

In my opinion, this requires less work (in the long run) than trying to cobble together a
macro or script that calls a sequence of "standard" operations.

In this case, trying to use "standard" tools probably involves converting to 8-bit integer (which
changes the values, requiring you to remember the mapping) and then displaying/measuring that 8-bit image.
My preference would be to process the original float image - perhaps creating an 8-bit image for display,
and at the same time accumulating the counts for each value range.  The primary advantage is that the
code would deal with the ORIGINAL values, and not a mapping onto [0,255].

Of course, someone will probably post a clever (and very simple) method using the "standard" ImageJ operations.
I look forward to this - I'm always eager to learn new methods.
============================================================================================

End rant.

--
Kenneth Sloan
[hidden email]
Vision is the art of seeing what is invisible to others.







 
>
> I have Optical coherence tomography (OCT) scan data in the form of intensity
> value for each pixel in an array of 309 x 826. I want to convert that data
> in the form of a greyscale image (min intensity: -22.3516 and Max intensity:
> 52.6367), say <0 dark grey but 0-10, 10-20,30-40 and >40 in the order of
> lighter grey to white and quantify each increase in the form of % and
> pixels. Thanks in advance for answering and helping out.
>
>  

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

Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Stein Rørvik
In reply to this post by CARL Philippe (LBP)
I would do the same as Philippe describes below, but create a 32-bit image since your input data appears to be floating point values. Then you will loose nothing; your image will be exactly the same as your data.

There is also an Import -> Text Image... command that takes a text based array from a file and creates an image from it. It expects the pixel values to be separated with tabs or spaces, and laid out in rows separated by linefeeds. Try that first. It also creates a 32-bit image for you if the numbers are floating point. If this works, you do not need a macro and will also get an image which is an exact match to your data.

Stein

-----Original Message-----
From: ImageJ Interest Group <[hidden email]> On Behalf Of CARL Philippe (LBP)
Sent: 8. november 2019 23:14
To: [hidden email]
Subject: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Kumar,
What you are looking for can easily be done by means of a small macro.
I would create a 309 x 826 pixels 8 bit picture setting by means of the setPixel method the lowest of your value to 0 and the highest to 255.
And to open the .csv file use File.openAsString on which result you apply the split method to extract the data for each pixel.
My best regards,
Philippe


Philippe CARL
Laboratoire de Bioimagerie et Pathologies UMR 7021 CNRS - Université de Strasbourg Faculté de Pharmacie
74 route du Rhin
67401 ILLKIRCH
Tel : +33(0)3 68 85 41 84

----- Mail original -----
De: "kumard" <[hidden email]>
À: "imagej" <[hidden email]>
Envoyé: Vendredi 8 Novembre 2019 22:25:05
Objet: intensity at each pixel in CSV format to open as greyscale image in imageJ

I have Optical coherence tomography (OCT) scan data in the form of intensity value for each pixel in an array of 309 x 826. I want to convert that data in the form of a greyscale image (min intensity: -22.3516 and Max intensity:
52.6367), say <0 dark grey but 0-10, 10-20,30-40 and >40 in the order of lighter grey to white and quantify each increase in the form of % and pixels. Thanks in advance for answering and helping out.



--
Sent from: https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fimagej.1557.x6.nabble.com%2F&amp;data=02%7C01%7Cstein.rorvik%40sintef.no%7C2f48742291e040f3329c08d7649c2473%7Ce1f00f39604145b0b309e0210d8b32af%7C1%7C0%7C637088494114634672&amp;sdata=y1taGEZNa5Cw%2B9ydB7mmWaVCJl0hII5l9fJp09Rcq0Q%3D&amp;reserved=0

--
ImageJ mailing list: https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fimagej.nih.gov%2Fij%2Flist.html&amp;data=02%7C01%7Cstein.rorvik%40sintef.no%7C2f48742291e040f3329c08d7649c2473%7Ce1f00f39604145b0b309e0210d8b32af%7C1%7C0%7C637088494114634672&amp;sdata=U8zbSeugB7fHL4gRZVp7%2FfzW%2BdY5TWMLQLA4X3VcotM%3D&amp;reserved=0

--
ImageJ mailing list: https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fimagej.nih.gov%2Fij%2Flist.html&amp;data=02%7C01%7Cstein.rorvik%40sintef.no%7C2f48742291e040f3329c08d7649c2473%7Ce1f00f39604145b0b309e0210d8b32af%7C1%7C0%7C637088494114634672&amp;sdata=U8zbSeugB7fHL4gRZVp7%2FfzW%2BdY5TWMLQLA4X3VcotM%3D&amp;reserved=0

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

Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Yongqiang Chen
In reply to this post by CARL Philippe (LBP)
Dear Philippe,

Can the setPix(x,y) be used on a series of images? Because the x and y are two dimensional. If there are 200 images. I wonder that how to operate the setPix(x,y) in "z" direction.

Best Regards,
Yongqiang

-----Original Message-----
From: CARL Philippe (LBP) <[hidden email]>
Sent: 08 November 2019 22:14
To: [hidden email]
Subject: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Kumar,
What you are looking for can easily be done by means of a small macro.
I would create a 309 x 826 pixels 8 bit picture setting by means of the setPixel method the lowest of your value to 0 and the highest to 255.
And to open the .csv file use File.openAsString on which result you apply the split method to extract the data for each pixel.
My best regards,
Philippe


Philippe CARL
Laboratoire de Bioimagerie et Pathologies UMR 7021 CNRS - Université de Strasbourg Faculté de Pharmacie
74 route du Rhin
67401 ILLKIRCH
Tel : +33(0)3 68 85 41 84

----- Mail original -----
De: "kumard" <[hidden email]>
À: "imagej" <[hidden email]>
Envoyé: Vendredi 8 Novembre 2019 22:25:05
Objet: intensity at each pixel in CSV format to open as greyscale image in imageJ

I have Optical coherence tomography (OCT) scan data in the form of intensity value for each pixel in an array of 309 x 826. I want to convert that data in the form of a greyscale image (min intensity: -22.3516 and Max intensity:
52.6367), say <0 dark grey but 0-10, 10-20,30-40 and >40 in the order of lighter grey to white and quantify each increase in the form of % and pixels. Thanks in advance for answering and helping out.



--
Sent from: http://imagej.1557.x6.nabble.com/

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

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

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

Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

CARL Philippe (LBP)
Dear Yongqiang,
For your question about having 200 images, you can have two choices.
So either create a stack of pictures (if think this is the best option) or alternatively create a picture for each of your file.
Please have as well a look to the answer of Stein.
I didn't know about the Import -> Text Image... feature he reported and the choice between creating a 8 or 32 bit depends whether you want to create a final picture where the values are only relative (8 Bit) or absolute (i.e. equal to your float input data for the 32 bit).
At last given that your request is very easy and quite fun, if you don't mind I could use it as prototypical example to teach my daughter how to program.
Thus in the case you want to acknowledge my proposal, just send me 2 of your .csv file and I will send you the needed macro (probably by tomorrow and for sure) before tuesday.
Take care and have a nice week-end.
My best regards,
Philippe

----- Mail original -----
De: "Yongqiang Chen" <[hidden email]>
À: "imagej" <[hidden email]>
Envoyé: Samedi 9 Novembre 2019 11:15:42
Objet: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Philippe,

Can the setPix(x,y) be used on a series of images? Because the x and y are two dimensional. If there are 200 images. I wonder that how to operate the setPix(x,y) in "z" direction.

Best Regards,
Yongqiang

-----Original Message-----
From: CARL Philippe (LBP) <[hidden email]>
Sent: 08 November 2019 22:14
To: [hidden email]
Subject: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Kumar,
What you are looking for can easily be done by means of a small macro.
I would create a 309 x 826 pixels 8 bit picture setting by means of the setPixel method the lowest of your value to 0 and the highest to 255.
And to open the .csv file use File.openAsString on which result you apply the split method to extract the data for each pixel.
My best regards,
Philippe


Philippe CARL
Laboratoire de Bioimagerie et Pathologies UMR 7021 CNRS - Université de Strasbourg Faculté de Pharmacie
74 route du Rhin
67401 ILLKIRCH
Tel : +33(0)3 68 85 41 84

----- Mail original -----
De: "kumard" <[hidden email]>
À: "imagej" <[hidden email]>
Envoyé: Vendredi 8 Novembre 2019 22:25:05
Objet: intensity at each pixel in CSV format to open as greyscale image in imageJ

I have Optical coherence tomography (OCT) scan data in the form of intensity value for each pixel in an array of 309 x 826. I want to convert that data in the form of a greyscale image (min intensity: -22.3516 and Max intensity:
52.6367), say <0 dark grey but 0-10, 10-20,30-40 and >40 in the order of lighter grey to white and quantify each increase in the form of % and pixels. Thanks in advance for answering and helping out.



--
Sent from: http://imagej.1557.x6.nabble.com/

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

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

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

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

Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Yongqiang Chen
Dear Philippe,

I don't understand the " alternatively create a picture for each of your file". Could you make it more easily understanding?

Regards,
Yongqiang


-----Original Message-----
From: CARL Philippe (LBP) <[hidden email]>
Sent: 09 November 2019 13:32
To: [hidden email]
Subject: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Yongqiang,
For your question about having 200 images, you can have two choices.
So either create a stack of pictures (if think this is the best option) or alternatively create a picture for each of your file.
Please have as well a look to the answer of Stein.
I didn't know about the Import -> Text Image... feature he reported and the choice between creating a 8 or 32 bit depends whether you want to create a final picture where the values are only relative (8 Bit) or absolute (i.e. equal to your float input data for the 32 bit).
At last given that your request is very easy and quite fun, if you don't mind I could use it as prototypical example to teach my daughter how to program.
Thus in the case you want to acknowledge my proposal, just send me 2 of your .csv file and I will send you the needed macro (probably by tomorrow and for sure) before tuesday.
Take care and have a nice week-end.
My best regards,
Philippe

----- Mail original -----
De: "Yongqiang Chen" <[hidden email]>
À: "imagej" <[hidden email]>
Envoyé: Samedi 9 Novembre 2019 11:15:42
Objet: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Philippe,

Can the setPix(x,y) be used on a series of images? Because the x and y are two dimensional. If there are 200 images. I wonder that how to operate the setPix(x,y) in "z" direction.

Best Regards,
Yongqiang

-----Original Message-----
From: CARL Philippe (LBP) <[hidden email]>
Sent: 08 November 2019 22:14
To: [hidden email]
Subject: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Kumar,
What you are looking for can easily be done by means of a small macro.
I would create a 309 x 826 pixels 8 bit picture setting by means of the setPixel method the lowest of your value to 0 and the highest to 255.
And to open the .csv file use File.openAsString on which result you apply the split method to extract the data for each pixel.
My best regards,
Philippe


Philippe CARL
Laboratoire de Bioimagerie et Pathologies UMR 7021 CNRS - Université de Strasbourg Faculté de Pharmacie
74 route du Rhin
67401 ILLKIRCH
Tel : +33(0)3 68 85 41 84

----- Mail original -----
De: "kumard" <[hidden email]>
À: "imagej" <[hidden email]>
Envoyé: Vendredi 8 Novembre 2019 22:25:05
Objet: intensity at each pixel in CSV format to open as greyscale image in imageJ

I have Optical coherence tomography (OCT) scan data in the form of intensity value for each pixel in an array of 309 x 826. I want to convert that data in the form of a greyscale image (min intensity: -22.3516 and Max intensity:
52.6367), say <0 dark grey but 0-10, 10-20,30-40 and >40 in the order of lighter grey to white and quantify each increase in the form of % and pixels. Thanks in advance for answering and helping out.



--
Sent from: http://imagej.1557.x6.nabble.com/

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

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

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

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

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

Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

CARL Philippe (LBP)
Dear Yongqiang;
A picture is a representation of two dimensionnal data which are either in 8 bit integer (i.e. between 0 and 255 = 2^8 - 1) or 16 bit (between 0 and 2^16 - 1) or 32 bit (float data).
So you can set the data of your picture with the setPixel(x, y, value) macro method and read them with the getPixel(x, y) method.
Thus if you have 200 .csv files (containing each the x and y data for only one picture) one option is to create a single picture for each of your .csv file (which is what I referenced by "alternatively create a picture for each of your file").
But what I think is much better is to simply create a stack picture with newImage(title, type, width, height, depth) and in your case depth will be equal to 200.
Then navigate from a stack slice to another with setSlice(n), FYI the n value of the setSlice(n) method is the "z" value of your previous question.
You can even push things further by setting a given slice label to the name of the corresponding source .csv file with run("Set Label...", "label=" + yourCSVFileName);
Hoping that I helped you to move further, please do not hesitate to contact me for further questions.
My best regards,
Philippe

----- Mail original -----
De: "Yongqiang Chen" <[hidden email]>
À: "imagej" <[hidden email]>
Envoyé: Samedi 9 Novembre 2019 14:43:11
Objet: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Philippe,

I don't understand the " alternatively create a picture for each of your file". Could you make it more easily understanding?

Regards,
Yongqiang


-----Original Message-----
From: CARL Philippe (LBP) <[hidden email]>
Sent: 09 November 2019 13:32
To: [hidden email]
Subject: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Yongqiang,
For your question about having 200 images, you can have two choices.
So either create a stack of pictures (if think this is the best option) or alternatively create a picture for each of your file.
Please have as well a look to the answer of Stein.
I didn't know about the Import -> Text Image... feature he reported and the choice between creating a 8 or 32 bit depends whether you want to create a final picture where the values are only relative (8 Bit) or absolute (i.e. equal to your float input data for the 32 bit).
At last given that your request is very easy and quite fun, if you don't mind I could use it as prototypical example to teach my daughter how to program.
Thus in the case you want to acknowledge my proposal, just send me 2 of your .csv file and I will send you the needed macro (probably by tomorrow and for sure) before tuesday.
Take care and have a nice week-end.
My best regards,
Philippe

----- Mail original -----
De: "Yongqiang Chen" <[hidden email]>
À: "imagej" <[hidden email]>
Envoyé: Samedi 9 Novembre 2019 11:15:42
Objet: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Philippe,

Can the setPix(x,y) be used on a series of images? Because the x and y are two dimensional. If there are 200 images. I wonder that how to operate the setPix(x,y) in "z" direction.

Best Regards,
Yongqiang

-----Original Message-----
From: CARL Philippe (LBP) <[hidden email]>
Sent: 08 November 2019 22:14
To: [hidden email]
Subject: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Kumar,
What you are looking for can easily be done by means of a small macro.
I would create a 309 x 826 pixels 8 bit picture setting by means of the setPixel method the lowest of your value to 0 and the highest to 255.
And to open the .csv file use File.openAsString on which result you apply the split method to extract the data for each pixel.
My best regards,
Philippe


Philippe CARL
Laboratoire de Bioimagerie et Pathologies UMR 7021 CNRS - Université de Strasbourg Faculté de Pharmacie
74 route du Rhin
67401 ILLKIRCH
Tel : +33(0)3 68 85 41 84

----- Mail original -----
De: "kumard" <[hidden email]>
À: "imagej" <[hidden email]>
Envoyé: Vendredi 8 Novembre 2019 22:25:05
Objet: intensity at each pixel in CSV format to open as greyscale image in imageJ

I have Optical coherence tomography (OCT) scan data in the form of intensity value for each pixel in an array of 309 x 826. I want to convert that data in the form of a greyscale image (min intensity: -22.3516 and Max intensity:
52.6367), say <0 dark grey but 0-10, 10-20,30-40 and >40 in the order of lighter grey to white and quantify each increase in the form of % and pixels. Thanks in advance for answering and helping out.



--
Sent from: http://imagej.1557.x6.nabble.com/

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

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

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

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

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

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

Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Yongqiang Chen
Dear Philippe,

Thank you for your patient detailed explanation. I think I got your point. I already tried the method and it works.

But it seems not too perfect in the imageJ. I didn’t find a Macro that can directly tell the depth of an unknown stack (how many slices in the stack). If there's a method that can return the size of slack, it would be nicer. So I am trying to use python to operate the pixel (don't know java...).

Thank you and have a good weekend.

Best Regards,
Yongqiang

-----Original Message-----
From: CARL Philippe (LBP) <[hidden email]>
Sent: 09 November 2019 14:18
To: [hidden email]
Subject: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Yongqiang;
A picture is a representation of two dimensionnal data which are either in 8 bit integer (i.e. between 0 and 255 = 2^8 - 1) or 16 bit (between 0 and 2^16 - 1) or 32 bit (float data).
So you can set the data of your picture with the setPixel(x, y, value) macro method and read them with the getPixel(x, y) method.
Thus if you have 200 .csv files (containing each the x and y data for only one picture) one option is to create a single picture for each of your .csv file (which is what I referenced by "alternatively create a picture for each of your file").
But what I think is much better is to simply create a stack picture with newImage(title, type, width, height, depth) and in your case depth will be equal to 200.
Then navigate from a stack slice to another with setSlice(n), FYI the n value of the setSlice(n) method is the "z" value of your previous question.
You can even push things further by setting a given slice label to the name of the corresponding source .csv file with run("Set Label...", "label=" + yourCSVFileName); Hoping that I helped you to move further, please do not hesitate to contact me for further questions.
My best regards,
Philippe

----- Mail original -----
De: "Yongqiang Chen" <[hidden email]>
À: "imagej" <[hidden email]>
Envoyé: Samedi 9 Novembre 2019 14:43:11
Objet: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Philippe,

I don't understand the " alternatively create a picture for each of your file". Could you make it more easily understanding?

Regards,
Yongqiang


-----Original Message-----
From: CARL Philippe (LBP) <[hidden email]>
Sent: 09 November 2019 13:32
To: [hidden email]
Subject: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Yongqiang,
For your question about having 200 images, you can have two choices.
So either create a stack of pictures (if think this is the best option) or alternatively create a picture for each of your file.
Please have as well a look to the answer of Stein.
I didn't know about the Import -> Text Image... feature he reported and the choice between creating a 8 or 32 bit depends whether you want to create a final picture where the values are only relative (8 Bit) or absolute (i.e. equal to your float input data for the 32 bit).
At last given that your request is very easy and quite fun, if you don't mind I could use it as prototypical example to teach my daughter how to program.
Thus in the case you want to acknowledge my proposal, just send me 2 of your .csv file and I will send you the needed macro (probably by tomorrow and for sure) before tuesday.
Take care and have a nice week-end.
My best regards,
Philippe

----- Mail original -----
De: "Yongqiang Chen" <[hidden email]>
À: "imagej" <[hidden email]>
Envoyé: Samedi 9 Novembre 2019 11:15:42
Objet: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Philippe,

Can the setPix(x,y) be used on a series of images? Because the x and y are two dimensional. If there are 200 images. I wonder that how to operate the setPix(x,y) in "z" direction.

Best Regards,
Yongqiang

-----Original Message-----
From: CARL Philippe (LBP) <[hidden email]>
Sent: 08 November 2019 22:14
To: [hidden email]
Subject: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Kumar,
What you are looking for can easily be done by means of a small macro.
I would create a 309 x 826 pixels 8 bit picture setting by means of the setPixel method the lowest of your value to 0 and the highest to 255.
And to open the .csv file use File.openAsString on which result you apply the split method to extract the data for each pixel.
My best regards,
Philippe


Philippe CARL
Laboratoire de Bioimagerie et Pathologies UMR 7021 CNRS - Université de Strasbourg Faculté de Pharmacie
74 route du Rhin
67401 ILLKIRCH
Tel : +33(0)3 68 85 41 84

----- Mail original -----
De: "kumard" <[hidden email]>
À: "imagej" <[hidden email]>
Envoyé: Vendredi 8 Novembre 2019 22:25:05
Objet: intensity at each pixel in CSV format to open as greyscale image in imageJ

I have Optical coherence tomography (OCT) scan data in the form of intensity value for each pixel in an array of 309 x 826. I want to convert that data in the form of a greyscale image (min intensity: -22.3516 and Max intensity:
52.6367), say <0 dark grey but 0-10, 10-20,30-40 and >40 in the order of lighter grey to white and quantify each increase in the form of % and pixels. Thanks in advance for answering and helping out.



--
Sent from: http://imagej.1557.x6.nabble.com/

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

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

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

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

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

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

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

Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Stein Rørvik
Back to what I suggested (importing as text image) I tried it and it works as expected with float values if these conditions are met:
- the decimal separator is a period
- the number separator is a tab, space or comma
- the lines are split by a newline character
Your CSV files most likely meet these requirements.

If your CSV can open as an image, all you have to do is to write a macro is that checks the folder and locates the CSV files by extension or similar (see the https://imagej.nih.gov/ij/macros/ListFilesRecursively.txt example) and then import each as an image using the Text Image command, like
run("Text Image... ", "open=C:/path/to/file/data123.csv");
After you have opened all files, you can use the images to stack command to create your stack. Since your files are relatively small, they should fit in memory. If not, you can convert the images one by one to TIFF, save them in a folder and import as a virtual stack.

Stein

-----Original Message-----
From: ImageJ Interest Group <[hidden email]> On Behalf Of Yongqiang Chen
Sent: 9. november 2019 15:32
To: [hidden email]
Subject: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Philippe,

Thank you for your patient detailed explanation. I think I got your point. I already tried the method and it works.

But it seems not too perfect in the imageJ. I didn’t find a Macro that can directly tell the depth of an unknown stack (how many slices in the stack). If there's a method that can return the size of slack, it would be nicer. So I am trying to use python to operate the pixel (don't know java...).

Thank you and have a good weekend.

Best Regards,
Yongqiang

-----Original Message-----
From: CARL Philippe (LBP) <[hidden email]>
Sent: 09 November 2019 14:18
To: [hidden email]
Subject: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Yongqiang;
A picture is a representation of two dimensionnal data which are either in 8 bit integer (i.e. between 0 and 255 = 2^8 - 1) or 16 bit (between 0 and 2^16 - 1) or 32 bit (float data).
So you can set the data of your picture with the setPixel(x, y, value) macro method and read them with the getPixel(x, y) method.
Thus if you have 200 .csv files (containing each the x and y data for only one picture) one option is to create a single picture for each of your .csv file (which is what I referenced by "alternatively create a picture for each of your file").
But what I think is much better is to simply create a stack picture with newImage(title, type, width, height, depth) and in your case depth will be equal to 200.
Then navigate from a stack slice to another with setSlice(n), FYI the n value of the setSlice(n) method is the "z" value of your previous question.
You can even push things further by setting a given slice label to the name of the corresponding source .csv file with run("Set Label...", "label=" + yourCSVFileName); Hoping that I helped you to move further, please do not hesitate to contact me for further questions.
My best regards,
Philippe

----- Mail original -----
De: "Yongqiang Chen" <[hidden email]>
À: "imagej" <[hidden email]>
Envoyé: Samedi 9 Novembre 2019 14:43:11
Objet: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Philippe,

I don't understand the " alternatively create a picture for each of your file". Could you make it more easily understanding?

Regards,
Yongqiang


-----Original Message-----
From: CARL Philippe (LBP) <[hidden email]>
Sent: 09 November 2019 13:32
To: [hidden email]
Subject: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Yongqiang,
For your question about having 200 images, you can have two choices.
So either create a stack of pictures (if think this is the best option) or alternatively create a picture for each of your file.
Please have as well a look to the answer of Stein.
I didn't know about the Import -> Text Image... feature he reported and the choice between creating a 8 or 32 bit depends whether you want to create a final picture where the values are only relative (8 Bit) or absolute (i.e. equal to your float input data for the 32 bit).
At last given that your request is very easy and quite fun, if you don't mind I could use it as prototypical example to teach my daughter how to program.
Thus in the case you want to acknowledge my proposal, just send me 2 of your .csv file and I will send you the needed macro (probably by tomorrow and for sure) before tuesday.
Take care and have a nice week-end.
My best regards,
Philippe

----- Mail original -----
De: "Yongqiang Chen" <[hidden email]>
À: "imagej" <[hidden email]>
Envoyé: Samedi 9 Novembre 2019 11:15:42
Objet: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Philippe,

Can the setPix(x,y) be used on a series of images? Because the x and y are two dimensional. If there are 200 images. I wonder that how to operate the setPix(x,y) in "z" direction.

Best Regards,
Yongqiang

-----Original Message-----
From: CARL Philippe (LBP) <[hidden email]>
Sent: 08 November 2019 22:14
To: [hidden email]
Subject: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Kumar,
What you are looking for can easily be done by means of a small macro.
I would create a 309 x 826 pixels 8 bit picture setting by means of the setPixel method the lowest of your value to 0 and the highest to 255.
And to open the .csv file use File.openAsString on which result you apply the split method to extract the data for each pixel.
My best regards,
Philippe


Philippe CARL
Laboratoire de Bioimagerie et Pathologies UMR 7021 CNRS - Université de Strasbourg Faculté de Pharmacie
74 route du Rhin
67401 ILLKIRCH
Tel : +33(0)3 68 85 41 84

----- Mail original -----
De: "kumard" <[hidden email]>
À: "imagej" <[hidden email]>
Envoyé: Vendredi 8 Novembre 2019 22:25:05
Objet: intensity at each pixel in CSV format to open as greyscale image in imageJ

I have Optical coherence tomography (OCT) scan data in the form of intensity value for each pixel in an array of 309 x 826. I want to convert that data in the form of a greyscale image (min intensity: -22.3516 and Max intensity:
52.6367), say <0 dark grey but 0-10, 10-20,30-40 and >40 in the order of lighter grey to white and quantify each increase in the form of % and pixels. Thanks in advance for answering and helping out.



--
Sent from: https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fimagej.1557.x6.nabble.com%2F&amp;data=02%7C01%7Cstein.rorvik%40sintef.no%7C3c6e060d197141f058ca08d76521bbac%7Ce1f00f39604145b0b309e0210d8b32af%7C1%7C1%7C637089067869004912&amp;sdata=HbSSK4QLo0wmoAOAEWIorwpAmYhl3lAm8zNkRocE%2Fc0%3D&amp;reserved=0

--
ImageJ mailing list: https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fimagej.nih.gov%2Fij%2Flist.html&amp;data=02%7C01%7Cstein.rorvik%40sintef.no%7C3c6e060d197141f058ca08d76521bbac%7Ce1f00f39604145b0b309e0210d8b32af%7C1%7C1%7C637089067869004912&amp;sdata=Od019Fi5PMTynr%2FaPQfccLdmtgKROFIL%2BrG1ddyX1cM%3D&amp;reserved=0

--
ImageJ mailing list: https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fimagej.nih.gov%2Fij%2Flist.html&amp;data=02%7C01%7Cstein.rorvik%40sintef.no%7C3c6e060d197141f058ca08d76521bbac%7Ce1f00f39604145b0b309e0210d8b32af%7C1%7C1%7C637089067869014903&amp;sdata=B3aEfqI%2BAbepvk5bZOohTmRsxJ3NxT7qKMoHiG2gCcY%3D&amp;reserved=0

--
ImageJ mailing list: https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fimagej.nih.gov%2Fij%2Flist.html&amp;data=02%7C01%7Cstein.rorvik%40sintef.no%7C3c6e060d197141f058ca08d76521bbac%7Ce1f00f39604145b0b309e0210d8b32af%7C1%7C1%7C637089067869014903&amp;sdata=B3aEfqI%2BAbepvk5bZOohTmRsxJ3NxT7qKMoHiG2gCcY%3D&amp;reserved=0

--
ImageJ mailing list: https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fimagej.nih.gov%2Fij%2Flist.html&amp;data=02%7C01%7Cstein.rorvik%40sintef.no%7C3c6e060d197141f058ca08d76521bbac%7Ce1f00f39604145b0b309e0210d8b32af%7C1%7C1%7C637089067869014903&amp;sdata=B3aEfqI%2BAbepvk5bZOohTmRsxJ3NxT7qKMoHiG2gCcY%3D&amp;reserved=0

--
ImageJ mailing list: https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fimagej.nih.gov%2Fij%2Flist.html&amp;data=02%7C01%7Cstein.rorvik%40sintef.no%7C3c6e060d197141f058ca08d76521bbac%7Ce1f00f39604145b0b309e0210d8b32af%7C1%7C1%7C637089067869014903&amp;sdata=B3aEfqI%2BAbepvk5bZOohTmRsxJ3NxT7qKMoHiG2gCcY%3D&amp;reserved=0

--
ImageJ mailing list: https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fimagej.nih.gov%2Fij%2Flist.html&amp;data=02%7C01%7Cstein.rorvik%40sintef.no%7C3c6e060d197141f058ca08d76521bbac%7Ce1f00f39604145b0b309e0210d8b32af%7C1%7C1%7C637089067869014903&amp;sdata=B3aEfqI%2BAbepvk5bZOohTmRsxJ3NxT7qKMoHiG2gCcY%3D&amp;reserved=0

--
ImageJ mailing list: https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fimagej.nih.gov%2Fij%2Flist.html&amp;data=02%7C01%7Cstein.rorvik%40sintef.no%7C3c6e060d197141f058ca08d76521bbac%7Ce1f00f39604145b0b309e0210d8b32af%7C1%7C1%7C637089067869014903&amp;sdata=B3aEfqI%2BAbepvk5bZOohTmRsxJ3NxT7qKMoHiG2gCcY%3D&amp;reserved=0

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

Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

CARL Philippe (LBP)
In reply to this post by Yongqiang Chen
Dear Yongqiang,
I can't really help you in Python since I only program in macro (for quick and dirty codes) and directly move over to Java in the case I need to more fancy or complicated things.
And for the macro programming, all the functions are reported here:
https://imagej.nih.gov/ij/developer/macro/functions.html
For your question:
"I didn’t find a Macro that can directly tell the depth of an unknown stack"
the answer is:
Stack.getDimensions(width, height, channels, slices, frames)
Good luck and have a nice week-end.
My best regards,
Philippe

----- Mail original -----
De: "Yongqiang Chen" <[hidden email]>
À: "imagej" <[hidden email]>
Envoyé: Samedi 9 Novembre 2019 15:31:50
Objet: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Philippe,

Thank you for your patient detailed explanation. I think I got your point. I already tried the method and it works.

But it seems not too perfect in the imageJ. I didn’t find a Macro that can directly tell the depth of an unknown stack (how many slices in the stack). If there's a method that can return the size of slack, it would be nicer. So I am trying to use python to operate the pixel (don't know java...).

Thank you and have a good weekend.

Best Regards,
Yongqiang

-----Original Message-----
From: CARL Philippe (LBP) <[hidden email]>
Sent: 09 November 2019 14:18
To: [hidden email]
Subject: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Yongqiang;
A picture is a representation of two dimensionnal data which are either in 8 bit integer (i.e. between 0 and 255 = 2^8 - 1) or 16 bit (between 0 and 2^16 - 1) or 32 bit (float data).
So you can set the data of your picture with the setPixel(x, y, value) macro method and read them with the getPixel(x, y) method.
Thus if you have 200 .csv files (containing each the x and y data for only one picture) one option is to create a single picture for each of your .csv file (which is what I referenced by "alternatively create a picture for each of your file").
But what I think is much better is to simply create a stack picture with newImage(title, type, width, height, depth) and in your case depth will be equal to 200.
Then navigate from a stack slice to another with setSlice(n), FYI the n value of the setSlice(n) method is the "z" value of your previous question.
You can even push things further by setting a given slice label to the name of the corresponding source .csv file with run("Set Label...", "label=" + yourCSVFileName); Hoping that I helped you to move further, please do not hesitate to contact me for further questions.
My best regards,
Philippe

----- Mail original -----
De: "Yongqiang Chen" <[hidden email]>
À: "imagej" <[hidden email]>
Envoyé: Samedi 9 Novembre 2019 14:43:11
Objet: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Philippe,

I don't understand the " alternatively create a picture for each of your file". Could you make it more easily understanding?

Regards,
Yongqiang


-----Original Message-----
From: CARL Philippe (LBP) <[hidden email]>
Sent: 09 November 2019 13:32
To: [hidden email]
Subject: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Yongqiang,
For your question about having 200 images, you can have two choices.
So either create a stack of pictures (if think this is the best option) or alternatively create a picture for each of your file.
Please have as well a look to the answer of Stein.
I didn't know about the Import -> Text Image... feature he reported and the choice between creating a 8 or 32 bit depends whether you want to create a final picture where the values are only relative (8 Bit) or absolute (i.e. equal to your float input data for the 32 bit).
At last given that your request is very easy and quite fun, if you don't mind I could use it as prototypical example to teach my daughter how to program.
Thus in the case you want to acknowledge my proposal, just send me 2 of your .csv file and I will send you the needed macro (probably by tomorrow and for sure) before tuesday.
Take care and have a nice week-end.
My best regards,
Philippe

----- Mail original -----
De: "Yongqiang Chen" <[hidden email]>
À: "imagej" <[hidden email]>
Envoyé: Samedi 9 Novembre 2019 11:15:42
Objet: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Philippe,

Can the setPix(x,y) be used on a series of images? Because the x and y are two dimensional. If there are 200 images. I wonder that how to operate the setPix(x,y) in "z" direction.

Best Regards,
Yongqiang

-----Original Message-----
From: CARL Philippe (LBP) <[hidden email]>
Sent: 08 November 2019 22:14
To: [hidden email]
Subject: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Kumar,
What you are looking for can easily be done by means of a small macro.
I would create a 309 x 826 pixels 8 bit picture setting by means of the setPixel method the lowest of your value to 0 and the highest to 255.
And to open the .csv file use File.openAsString on which result you apply the split method to extract the data for each pixel.
My best regards,
Philippe


Philippe CARL
Laboratoire de Bioimagerie et Pathologies UMR 7021 CNRS - Université de Strasbourg Faculté de Pharmacie
74 route du Rhin
67401 ILLKIRCH
Tel : +33(0)3 68 85 41 84

----- Mail original -----
De: "kumard" <[hidden email]>
À: "imagej" <[hidden email]>
Envoyé: Vendredi 8 Novembre 2019 22:25:05
Objet: intensity at each pixel in CSV format to open as greyscale image in imageJ

I have Optical coherence tomography (OCT) scan data in the form of intensity value for each pixel in an array of 309 x 826. I want to convert that data in the form of a greyscale image (min intensity: -22.3516 and Max intensity:
52.6367), say <0 dark grey but 0-10, 10-20,30-40 and >40 in the order of lighter grey to white and quantify each increase in the form of % and pixels. Thanks in advance for answering and helping out.



--
Sent from: http://imagej.1557.x6.nabble.com/

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

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

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

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

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

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

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

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

Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Yongqiang Chen
Dear Philippe,

Thank you so much for the information.
But I check the macro on the website. It says that " Stack.getDimensions(width, height, channels, slices, frames) Returns the dimensions of the current image". It means that it will return the dimension of the current image. So this dimension is only for a single slice. It may not work for the slice number of the stack.

Best Regards,
Yongqiang

-----Original Message-----
From: CARL Philippe (LBP) <[hidden email]>
Sent: 09 November 2019 14:40
To: [hidden email]
Subject: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Yongqiang,
I can't really help you in Python since I only program in macro (for quick and dirty codes) and directly move over to Java in the case I need to more fancy or complicated things.
And for the macro programming, all the functions are reported here:
https://imagej.nih.gov/ij/developer/macro/functions.html
For your question:
"I didn’t find a Macro that can directly tell the depth of an unknown stack"
the answer is:
Stack.getDimensions(width, height, channels, slices, frames) Good luck and have a nice week-end.
My best regards,
Philippe

----- Mail original -----
De: "Yongqiang Chen" <[hidden email]>
À: "imagej" <[hidden email]>
Envoyé: Samedi 9 Novembre 2019 15:31:50
Objet: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Philippe,

Thank you for your patient detailed explanation. I think I got your point. I already tried the method and it works.

But it seems not too perfect in the imageJ. I didn’t find a Macro that can directly tell the depth of an unknown stack (how many slices in the stack). If there's a method that can return the size of slack, it would be nicer. So I am trying to use python to operate the pixel (don't know java...).

Thank you and have a good weekend.

Best Regards,
Yongqiang

-----Original Message-----
From: CARL Philippe (LBP) <[hidden email]>
Sent: 09 November 2019 14:18
To: [hidden email]
Subject: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Yongqiang;
A picture is a representation of two dimensionnal data which are either in 8 bit integer (i.e. between 0 and 255 = 2^8 - 1) or 16 bit (between 0 and 2^16 - 1) or 32 bit (float data).
So you can set the data of your picture with the setPixel(x, y, value) macro method and read them with the getPixel(x, y) method.
Thus if you have 200 .csv files (containing each the x and y data for only one picture) one option is to create a single picture for each of your .csv file (which is what I referenced by "alternatively create a picture for each of your file").
But what I think is much better is to simply create a stack picture with newImage(title, type, width, height, depth) and in your case depth will be equal to 200.
Then navigate from a stack slice to another with setSlice(n), FYI the n value of the setSlice(n) method is the "z" value of your previous question.
You can even push things further by setting a given slice label to the name of the corresponding source .csv file with run("Set Label...", "label=" + yourCSVFileName); Hoping that I helped you to move further, please do not hesitate to contact me for further questions.
My best regards,
Philippe

----- Mail original -----
De: "Yongqiang Chen" <[hidden email]>
À: "imagej" <[hidden email]>
Envoyé: Samedi 9 Novembre 2019 14:43:11
Objet: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Philippe,

I don't understand the " alternatively create a picture for each of your file". Could you make it more easily understanding?

Regards,
Yongqiang


-----Original Message-----
From: CARL Philippe (LBP) <[hidden email]>
Sent: 09 November 2019 13:32
To: [hidden email]
Subject: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Yongqiang,
For your question about having 200 images, you can have two choices.
So either create a stack of pictures (if think this is the best option) or alternatively create a picture for each of your file.
Please have as well a look to the answer of Stein.
I didn't know about the Import -> Text Image... feature he reported and the choice between creating a 8 or 32 bit depends whether you want to create a final picture where the values are only relative (8 Bit) or absolute (i.e. equal to your float input data for the 32 bit).
At last given that your request is very easy and quite fun, if you don't mind I could use it as prototypical example to teach my daughter how to program.
Thus in the case you want to acknowledge my proposal, just send me 2 of your .csv file and I will send you the needed macro (probably by tomorrow and for sure) before tuesday.
Take care and have a nice week-end.
My best regards,
Philippe

----- Mail original -----
De: "Yongqiang Chen" <[hidden email]>
À: "imagej" <[hidden email]>
Envoyé: Samedi 9 Novembre 2019 11:15:42
Objet: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Philippe,

Can the setPix(x,y) be used on a series of images? Because the x and y are two dimensional. If there are 200 images. I wonder that how to operate the setPix(x,y) in "z" direction.

Best Regards,
Yongqiang

-----Original Message-----
From: CARL Philippe (LBP) <[hidden email]>
Sent: 08 November 2019 22:14
To: [hidden email]
Subject: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Kumar,
What you are looking for can easily be done by means of a small macro.
I would create a 309 x 826 pixels 8 bit picture setting by means of the setPixel method the lowest of your value to 0 and the highest to 255.
And to open the .csv file use File.openAsString on which result you apply the split method to extract the data for each pixel.
My best regards,
Philippe


Philippe CARL
Laboratoire de Bioimagerie et Pathologies UMR 7021 CNRS - Université de Strasbourg Faculté de Pharmacie
74 route du Rhin
67401 ILLKIRCH
Tel : +33(0)3 68 85 41 84

----- Mail original -----
De: "kumard" <[hidden email]>
À: "imagej" <[hidden email]>
Envoyé: Vendredi 8 Novembre 2019 22:25:05
Objet: intensity at each pixel in CSV format to open as greyscale image in imageJ

I have Optical coherence tomography (OCT) scan data in the form of intensity value for each pixel in an array of 309 x 826. I want to convert that data in the form of a greyscale image (min intensity: -22.3516 and Max intensity:
52.6367), say <0 dark grey but 0-10, 10-20,30-40 and >40 in the order of lighter grey to white and quantify each increase in the form of % and pixels. Thanks in advance for answering and helping out.



--
Sent from: http://imagej.1557.x6.nabble.com/

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

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

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

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

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

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

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

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

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

Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

CARL Philippe (LBP)
Dear Yongqiang,
Launching the method "Stack.getDimensions(width, height, channels, slices, frames)"
will return you 5 parameters or results:
- width   which is the width  of your given picture
- height  which is the height of your given picture
- channel which is the number of channels it has, which is probably 1 for you.
- slices  which is the number of channels it has, which is the information you are looking for
- frames  which is the number of time frames it has.
Also if you are sure frames is 1 in your case or don't use it's value, you can alternatively launch:
"Stack.getDimensions(width, height, channels, slices)"
And you can even launch
"Stack.getDimensions(bob  , john  , peter   , lenna)"
lenna being then the slice size you are looking for.
My best regards,
Philippe

----- Mail original -----
De: "Yongqiang Chen" <[hidden email]>
À: "imagej" <[hidden email]>
Envoyé: Samedi 9 Novembre 2019 15:47:25
Objet: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Philippe,

Thank you so much for the information.
But I check the macro on the website. It says that " Stack.getDimensions(width, height, channels, slices, frames) Returns the dimensions of the current image". It means that it will return the dimension of the current image. So this dimension is only for a single slice. It may not work for the slice number of the stack.

Best Regards,
Yongqiang

-----Original Message-----
From: CARL Philippe (LBP) <[hidden email]>
Sent: 09 November 2019 14:40
To: [hidden email]
Subject: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Yongqiang,
I can't really help you in Python since I only program in macro (for quick and dirty codes) and directly move over to Java in the case I need to more fancy or complicated things.
And for the macro programming, all the functions are reported here:
https://imagej.nih.gov/ij/developer/macro/functions.html
For your question:
"I didn’t find a Macro that can directly tell the depth of an unknown stack"
the answer is:
Stack.getDimensions(width, height, channels, slices, frames) Good luck and have a nice week-end.
My best regards,
Philippe

----- Mail original -----
De: "Yongqiang Chen" <[hidden email]>
À: "imagej" <[hidden email]>
Envoyé: Samedi 9 Novembre 2019 15:31:50
Objet: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Philippe,

Thank you for your patient detailed explanation. I think I got your point. I already tried the method and it works.

But it seems not too perfect in the imageJ. I didn’t find a Macro that can directly tell the depth of an unknown stack (how many slices in the stack). If there's a method that can return the size of slack, it would be nicer. So I am trying to use python to operate the pixel (don't know java...).

Thank you and have a good weekend.

Best Regards,
Yongqiang

-----Original Message-----
From: CARL Philippe (LBP) <[hidden email]>
Sent: 09 November 2019 14:18
To: [hidden email]
Subject: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Yongqiang;
A picture is a representation of two dimensionnal data which are either in 8 bit integer (i.e. between 0 and 255 = 2^8 - 1) or 16 bit (between 0 and 2^16 - 1) or 32 bit (float data).
So you can set the data of your picture with the setPixel(x, y, value) macro method and read them with the getPixel(x, y) method.
Thus if you have 200 .csv files (containing each the x and y data for only one picture) one option is to create a single picture for each of your .csv file (which is what I referenced by "alternatively create a picture for each of your file").
But what I think is much better is to simply create a stack picture with newImage(title, type, width, height, depth) and in your case depth will be equal to 200.
Then navigate from a stack slice to another with setSlice(n), FYI the n value of the setSlice(n) method is the "z" value of your previous question.
You can even push things further by setting a given slice label to the name of the corresponding source .csv file with run("Set Label...", "label=" + yourCSVFileName); Hoping that I helped you to move further, please do not hesitate to contact me for further questions.
My best regards,
Philippe

----- Mail original -----
De: "Yongqiang Chen" <[hidden email]>
À: "imagej" <[hidden email]>
Envoyé: Samedi 9 Novembre 2019 14:43:11
Objet: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Philippe,

I don't understand the " alternatively create a picture for each of your file". Could you make it more easily understanding?

Regards,
Yongqiang


-----Original Message-----
From: CARL Philippe (LBP) <[hidden email]>
Sent: 09 November 2019 13:32
To: [hidden email]
Subject: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Yongqiang,
For your question about having 200 images, you can have two choices.
So either create a stack of pictures (if think this is the best option) or alternatively create a picture for each of your file.
Please have as well a look to the answer of Stein.
I didn't know about the Import -> Text Image... feature he reported and the choice between creating a 8 or 32 bit depends whether you want to create a final picture where the values are only relative (8 Bit) or absolute (i.e. equal to your float input data for the 32 bit).
At last given that your request is very easy and quite fun, if you don't mind I could use it as prototypical example to teach my daughter how to program.
Thus in the case you want to acknowledge my proposal, just send me 2 of your .csv file and I will send you the needed macro (probably by tomorrow and for sure) before tuesday.
Take care and have a nice week-end.
My best regards,
Philippe

----- Mail original -----
De: "Yongqiang Chen" <[hidden email]>
À: "imagej" <[hidden email]>
Envoyé: Samedi 9 Novembre 2019 11:15:42
Objet: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Philippe,

Can the setPix(x,y) be used on a series of images? Because the x and y are two dimensional. If there are 200 images. I wonder that how to operate the setPix(x,y) in "z" direction.

Best Regards,
Yongqiang

-----Original Message-----
From: CARL Philippe (LBP) <[hidden email]>
Sent: 08 November 2019 22:14
To: [hidden email]
Subject: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Kumar,
What you are looking for can easily be done by means of a small macro.
I would create a 309 x 826 pixels 8 bit picture setting by means of the setPixel method the lowest of your value to 0 and the highest to 255.
And to open the .csv file use File.openAsString on which result you apply the split method to extract the data for each pixel.
My best regards,
Philippe


Philippe CARL
Laboratoire de Bioimagerie et Pathologies UMR 7021 CNRS - Université de Strasbourg Faculté de Pharmacie
74 route du Rhin
67401 ILLKIRCH
Tel : +33(0)3 68 85 41 84

----- Mail original -----
De: "kumard" <[hidden email]>
À: "imagej" <[hidden email]>
Envoyé: Vendredi 8 Novembre 2019 22:25:05
Objet: intensity at each pixel in CSV format to open as greyscale image in imageJ

I have Optical coherence tomography (OCT) scan data in the form of intensity value for each pixel in an array of 309 x 826. I want to convert that data in the form of a greyscale image (min intensity: -22.3516 and Max intensity:
52.6367), say <0 dark grey but 0-10, 10-20,30-40 and >40 in the order of lighter grey to white and quantify each increase in the form of % and pixels. Thanks in advance for answering and helping out.



--
Sent from: http://imagej.1557.x6.nabble.com/

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

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

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

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

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

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

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

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

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

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

Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Yongqiang Chen
Dear Philippe,

Thank you very much.
I will try it and let you know if it works (next week). Thank you very much for your help. Enjoy the weekend.

Regards,
Yongqiang


-----Original Message-----
From: CARL Philippe (LBP) <[hidden email]>
Sent: 09 November 2019 14:58
To: [hidden email]
Subject: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Yongqiang,
Launching the method "Stack.getDimensions(width, height, channels, slices, frames)"
will return you 5 parameters or results:
- width   which is the width  of your given picture
- height  which is the height of your given picture
- channel which is the number of channels it has, which is probably 1 for you.
- slices  which is the number of channels it has, which is the information you are looking for
- frames  which is the number of time frames it has.
Also if you are sure frames is 1 in your case or don't use it's value, you can alternatively launch:
"Stack.getDimensions(width, height, channels, slices)"
And you can even launch
"Stack.getDimensions(bob  , john  , peter   , lenna)"
lenna being then the slice size you are looking for.
My best regards,
Philippe

----- Mail original -----
De: "Yongqiang Chen" <[hidden email]>
À: "imagej" <[hidden email]>
Envoyé: Samedi 9 Novembre 2019 15:47:25
Objet: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Philippe,

Thank you so much for the information.
But I check the macro on the website. It says that " Stack.getDimensions(width, height, channels, slices, frames) Returns the dimensions of the current image". It means that it will return the dimension of the current image. So this dimension is only for a single slice. It may not work for the slice number of the stack.

Best Regards,
Yongqiang

-----Original Message-----
From: CARL Philippe (LBP) <[hidden email]>
Sent: 09 November 2019 14:40
To: [hidden email]
Subject: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Yongqiang,
I can't really help you in Python since I only program in macro (for quick and dirty codes) and directly move over to Java in the case I need to more fancy or complicated things.
And for the macro programming, all the functions are reported here:
https://imagej.nih.gov/ij/developer/macro/functions.html
For your question:
"I didn’t find a Macro that can directly tell the depth of an unknown stack"
the answer is:
Stack.getDimensions(width, height, channels, slices, frames) Good luck and have a nice week-end.
My best regards,
Philippe

----- Mail original -----
De: "Yongqiang Chen" <[hidden email]>
À: "imagej" <[hidden email]>
Envoyé: Samedi 9 Novembre 2019 15:31:50
Objet: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Philippe,

Thank you for your patient detailed explanation. I think I got your point. I already tried the method and it works.

But it seems not too perfect in the imageJ. I didn’t find a Macro that can directly tell the depth of an unknown stack (how many slices in the stack). If there's a method that can return the size of slack, it would be nicer. So I am trying to use python to operate the pixel (don't know java...).

Thank you and have a good weekend.

Best Regards,
Yongqiang

-----Original Message-----
From: CARL Philippe (LBP) <[hidden email]>
Sent: 09 November 2019 14:18
To: [hidden email]
Subject: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Yongqiang;
A picture is a representation of two dimensionnal data which are either in 8 bit integer (i.e. between 0 and 255 = 2^8 - 1) or 16 bit (between 0 and 2^16 - 1) or 32 bit (float data).
So you can set the data of your picture with the setPixel(x, y, value) macro method and read them with the getPixel(x, y) method.
Thus if you have 200 .csv files (containing each the x and y data for only one picture) one option is to create a single picture for each of your .csv file (which is what I referenced by "alternatively create a picture for each of your file").
But what I think is much better is to simply create a stack picture with newImage(title, type, width, height, depth) and in your case depth will be equal to 200.
Then navigate from a stack slice to another with setSlice(n), FYI the n value of the setSlice(n) method is the "z" value of your previous question.
You can even push things further by setting a given slice label to the name of the corresponding source .csv file with run("Set Label...", "label=" + yourCSVFileName); Hoping that I helped you to move further, please do not hesitate to contact me for further questions.
My best regards,
Philippe

----- Mail original -----
De: "Yongqiang Chen" <[hidden email]>
À: "imagej" <[hidden email]>
Envoyé: Samedi 9 Novembre 2019 14:43:11
Objet: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Philippe,

I don't understand the " alternatively create a picture for each of your file". Could you make it more easily understanding?

Regards,
Yongqiang


-----Original Message-----
From: CARL Philippe (LBP) <[hidden email]>
Sent: 09 November 2019 13:32
To: [hidden email]
Subject: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Yongqiang,
For your question about having 200 images, you can have two choices.
So either create a stack of pictures (if think this is the best option) or alternatively create a picture for each of your file.
Please have as well a look to the answer of Stein.
I didn't know about the Import -> Text Image... feature he reported and the choice between creating a 8 or 32 bit depends whether you want to create a final picture where the values are only relative (8 Bit) or absolute (i.e. equal to your float input data for the 32 bit).
At last given that your request is very easy and quite fun, if you don't mind I could use it as prototypical example to teach my daughter how to program.
Thus in the case you want to acknowledge my proposal, just send me 2 of your .csv file and I will send you the needed macro (probably by tomorrow and for sure) before tuesday.
Take care and have a nice week-end.
My best regards,
Philippe

----- Mail original -----
De: "Yongqiang Chen" <[hidden email]>
À: "imagej" <[hidden email]>
Envoyé: Samedi 9 Novembre 2019 11:15:42
Objet: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Philippe,

Can the setPix(x,y) be used on a series of images? Because the x and y are two dimensional. If there are 200 images. I wonder that how to operate the setPix(x,y) in "z" direction.

Best Regards,
Yongqiang

-----Original Message-----
From: CARL Philippe (LBP) <[hidden email]>
Sent: 08 November 2019 22:14
To: [hidden email]
Subject: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Kumar,
What you are looking for can easily be done by means of a small macro.
I would create a 309 x 826 pixels 8 bit picture setting by means of the setPixel method the lowest of your value to 0 and the highest to 255.
And to open the .csv file use File.openAsString on which result you apply the split method to extract the data for each pixel.
My best regards,
Philippe


Philippe CARL
Laboratoire de Bioimagerie et Pathologies UMR 7021 CNRS - Université de Strasbourg Faculté de Pharmacie
74 route du Rhin
67401 ILLKIRCH
Tel : +33(0)3 68 85 41 84

----- Mail original -----
De: "kumard" <[hidden email]>
À: "imagej" <[hidden email]>
Envoyé: Vendredi 8 Novembre 2019 22:25:05
Objet: intensity at each pixel in CSV format to open as greyscale image in imageJ

I have Optical coherence tomography (OCT) scan data in the form of intensity value for each pixel in an array of 309 x 826. I want to convert that data in the form of a greyscale image (min intensity: -22.3516 and Max intensity:
52.6367), say <0 dark grey but 0-10, 10-20,30-40 and >40 in the order of lighter grey to white and quantify each increase in the form of % and pixels. Thanks in advance for answering and helping out.



--
Sent from: http://imagej.1557.x6.nabble.com/

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

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

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

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

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

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

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

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

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

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

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

Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Yongqiang Chen
In reply to this post by CARL Philippe (LBP)
Hi Philippe,

I tried the method. But it did not work in this case. Instead, using "nSlices" directly can return the slice number in the stack.

Best Regards,
Yongqiang

-----Original Message-----
From: CARL Philippe (LBP) <[hidden email]>
Sent: 09 November 2019 14:58
To: [hidden email]
Subject: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Yongqiang,
Launching the method "Stack.getDimensions(width, height, channels, slices, frames)"
will return you 5 parameters or results:
- width   which is the width  of your given picture
- height  which is the height of your given picture
- channel which is the number of channels it has, which is probably 1 for you.
- slices  which is the number of channels it has, which is the information you are looking for
- frames  which is the number of time frames it has.
Also if you are sure frames is 1 in your case or don't use it's value, you can alternatively launch:
"Stack.getDimensions(width, height, channels, slices)"
And you can even launch
"Stack.getDimensions(bob  , john  , peter   , lenna)"
lenna being then the slice size you are looking for.
My best regards,
Philippe

----- Mail original -----
De: "Yongqiang Chen" <[hidden email]>
À: "imagej" <[hidden email]>
Envoyé: Samedi 9 Novembre 2019 15:47:25
Objet: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Philippe,

Thank you so much for the information.
But I check the macro on the website. It says that " Stack.getDimensions(width, height, channels, slices, frames) Returns the dimensions of the current image". It means that it will return the dimension of the current image. So this dimension is only for a single slice. It may not work for the slice number of the stack.

Best Regards,
Yongqiang

-----Original Message-----
From: CARL Philippe (LBP) <[hidden email]>
Sent: 09 November 2019 14:40
To: [hidden email]
Subject: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Yongqiang,
I can't really help you in Python since I only program in macro (for quick and dirty codes) and directly move over to Java in the case I need to more fancy or complicated things.
And for the macro programming, all the functions are reported here:
https://imagej.nih.gov/ij/developer/macro/functions.html
For your question:
"I didn’t find a Macro that can directly tell the depth of an unknown stack"
the answer is:
Stack.getDimensions(width, height, channels, slices, frames) Good luck and have a nice week-end.
My best regards,
Philippe

----- Mail original -----
De: "Yongqiang Chen" <[hidden email]>
À: "imagej" <[hidden email]>
Envoyé: Samedi 9 Novembre 2019 15:31:50
Objet: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Philippe,

Thank you for your patient detailed explanation. I think I got your point. I already tried the method and it works.

But it seems not too perfect in the imageJ. I didn’t find a Macro that can directly tell the depth of an unknown stack (how many slices in the stack). If there's a method that can return the size of slack, it would be nicer. So I am trying to use python to operate the pixel (don't know java...).

Thank you and have a good weekend.

Best Regards,
Yongqiang

-----Original Message-----
From: CARL Philippe (LBP) <[hidden email]>
Sent: 09 November 2019 14:18
To: [hidden email]
Subject: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Yongqiang;
A picture is a representation of two dimensionnal data which are either in 8 bit integer (i.e. between 0 and 255 = 2^8 - 1) or 16 bit (between 0 and 2^16 - 1) or 32 bit (float data).
So you can set the data of your picture with the setPixel(x, y, value) macro method and read them with the getPixel(x, y) method.
Thus if you have 200 .csv files (containing each the x and y data for only one picture) one option is to create a single picture for each of your .csv file (which is what I referenced by "alternatively create a picture for each of your file").
But what I think is much better is to simply create a stack picture with newImage(title, type, width, height, depth) and in your case depth will be equal to 200.
Then navigate from a stack slice to another with setSlice(n), FYI the n value of the setSlice(n) method is the "z" value of your previous question.
You can even push things further by setting a given slice label to the name of the corresponding source .csv file with run("Set Label...", "label=" + yourCSVFileName); Hoping that I helped you to move further, please do not hesitate to contact me for further questions.
My best regards,
Philippe

----- Mail original -----
De: "Yongqiang Chen" <[hidden email]>
À: "imagej" <[hidden email]>
Envoyé: Samedi 9 Novembre 2019 14:43:11
Objet: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Philippe,

I don't understand the " alternatively create a picture for each of your file". Could you make it more easily understanding?

Regards,
Yongqiang


-----Original Message-----
From: CARL Philippe (LBP) <[hidden email]>
Sent: 09 November 2019 13:32
To: [hidden email]
Subject: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Yongqiang,
For your question about having 200 images, you can have two choices.
So either create a stack of pictures (if think this is the best option) or alternatively create a picture for each of your file.
Please have as well a look to the answer of Stein.
I didn't know about the Import -> Text Image... feature he reported and the choice between creating a 8 or 32 bit depends whether you want to create a final picture where the values are only relative (8 Bit) or absolute (i.e. equal to your float input data for the 32 bit).
At last given that your request is very easy and quite fun, if you don't mind I could use it as prototypical example to teach my daughter how to program.
Thus in the case you want to acknowledge my proposal, just send me 2 of your .csv file and I will send you the needed macro (probably by tomorrow and for sure) before tuesday.
Take care and have a nice week-end.
My best regards,
Philippe

----- Mail original -----
De: "Yongqiang Chen" <[hidden email]>
À: "imagej" <[hidden email]>
Envoyé: Samedi 9 Novembre 2019 11:15:42
Objet: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Philippe,

Can the setPix(x,y) be used on a series of images? Because the x and y are two dimensional. If there are 200 images. I wonder that how to operate the setPix(x,y) in "z" direction.

Best Regards,
Yongqiang

-----Original Message-----
From: CARL Philippe (LBP) <[hidden email]>
Sent: 08 November 2019 22:14
To: [hidden email]
Subject: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Kumar,
What you are looking for can easily be done by means of a small macro.
I would create a 309 x 826 pixels 8 bit picture setting by means of the setPixel method the lowest of your value to 0 and the highest to 255.
And to open the .csv file use File.openAsString on which result you apply the split method to extract the data for each pixel.
My best regards,
Philippe


Philippe CARL
Laboratoire de Bioimagerie et Pathologies UMR 7021 CNRS - Université de Strasbourg Faculté de Pharmacie
74 route du Rhin
67401 ILLKIRCH
Tel : +33(0)3 68 85 41 84

----- Mail original -----
De: "kumard" <[hidden email]>
À: "imagej" <[hidden email]>
Envoyé: Vendredi 8 Novembre 2019 22:25:05
Objet: intensity at each pixel in CSV format to open as greyscale image in imageJ

I have Optical coherence tomography (OCT) scan data in the form of intensity value for each pixel in an array of 309 x 826. I want to convert that data in the form of a greyscale image (min intensity: -22.3516 and Max intensity:
52.6367), say <0 dark grey but 0-10, 10-20,30-40 and >40 in the order of lighter grey to white and quantify each increase in the form of % and pixels. Thanks in advance for answering and helping out.



--
Sent from: http://imagej.1557.x6.nabble.com/

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

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

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

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

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

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

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

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

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

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

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

Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

CARL Philippe (LBP)
Dear Yongqiang,

> Instead, using "nSlices" directly can return the slice number in the stack.

You are fully right: I forget about "nSlices" and it is indeed way more ad hoc than the solution I proposed!

> I tried the method. But it did not work in this case.

Nevertheless the solution I proposed HAS to work:

With nSlices you can do right away:
for(i = 1; i <= nSlices; i++)
{.....

With the solution I proposed you just do:
Stack.getDimensions(bob, john, peter, lenna);
for(i = 1; i <= lenna; i++)
{.....

but both have to work!

My best regards,

Philippe

----- Mail original -----
De: "Yongqiang Chen" <[hidden email]>
À: "imagej" <[hidden email]>
Envoyé: Samedi 9 Novembre 2019 16:26:11
Objet: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Hi Philippe,

I tried the method. But it did not work in this case. Instead, using "nSlices" directly can return the slice number in the stack.

Best Regards,
Yongqiang

-----Original Message-----
From: CARL Philippe (LBP) <[hidden email]>
Sent: 09 November 2019 14:58
To: [hidden email]
Subject: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Yongqiang,
Launching the method "Stack.getDimensions(width, height, channels, slices, frames)"
will return you 5 parameters or results:
- width   which is the width  of your given picture
- height  which is the height of your given picture
- channel which is the number of channels it has, which is probably 1 for you.
- slices  which is the number of channels it has, which is the information you are looking for
- frames  which is the number of time frames it has.
Also if you are sure frames is 1 in your case or don't use it's value, you can alternatively launch:
"Stack.getDimensions(width, height, channels, slices)"
And you can even launch
"Stack.getDimensions(bob  , john  , peter   , lenna)"
lenna being then the slice size you are looking for.
My best regards,
Philippe

----- Mail original -----
De: "Yongqiang Chen" <[hidden email]>
À: "imagej" <[hidden email]>
Envoyé: Samedi 9 Novembre 2019 15:47:25
Objet: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Philippe,

Thank you so much for the information.
But I check the macro on the website. It says that " Stack.getDimensions(width, height, channels, slices, frames) Returns the dimensions of the current image". It means that it will return the dimension of the current image. So this dimension is only for a single slice. It may not work for the slice number of the stack.

Best Regards,
Yongqiang

-----Original Message-----
From: CARL Philippe (LBP) <[hidden email]>
Sent: 09 November 2019 14:40
To: [hidden email]
Subject: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Yongqiang,
I can't really help you in Python since I only program in macro (for quick and dirty codes) and directly move over to Java in the case I need to more fancy or complicated things.
And for the macro programming, all the functions are reported here:
https://imagej.nih.gov/ij/developer/macro/functions.html
For your question:
"I didn’t find a Macro that can directly tell the depth of an unknown stack"
the answer is:
Stack.getDimensions(width, height, channels, slices, frames) Good luck and have a nice week-end.
My best regards,
Philippe

----- Mail original -----
De: "Yongqiang Chen" <[hidden email]>
À: "imagej" <[hidden email]>
Envoyé: Samedi 9 Novembre 2019 15:31:50
Objet: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Philippe,

Thank you for your patient detailed explanation. I think I got your point. I already tried the method and it works.

But it seems not too perfect in the imageJ. I didn’t find a Macro that can directly tell the depth of an unknown stack (how many slices in the stack). If there's a method that can return the size of slack, it would be nicer. So I am trying to use python to operate the pixel (don't know java...).

Thank you and have a good weekend.

Best Regards,
Yongqiang

-----Original Message-----
From: CARL Philippe (LBP) <[hidden email]>
Sent: 09 November 2019 14:18
To: [hidden email]
Subject: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Yongqiang;
A picture is a representation of two dimensionnal data which are either in 8 bit integer (i.e. between 0 and 255 = 2^8 - 1) or 16 bit (between 0 and 2^16 - 1) or 32 bit (float data).
So you can set the data of your picture with the setPixel(x, y, value) macro method and read them with the getPixel(x, y) method.
Thus if you have 200 .csv files (containing each the x and y data for only one picture) one option is to create a single picture for each of your .csv file (which is what I referenced by "alternatively create a picture for each of your file").
But what I think is much better is to simply create a stack picture with newImage(title, type, width, height, depth) and in your case depth will be equal to 200.
Then navigate from a stack slice to another with setSlice(n), FYI the n value of the setSlice(n) method is the "z" value of your previous question.
You can even push things further by setting a given slice label to the name of the corresponding source .csv file with run("Set Label...", "label=" + yourCSVFileName); Hoping that I helped you to move further, please do not hesitate to contact me for further questions.
My best regards,
Philippe

----- Mail original -----
De: "Yongqiang Chen" <[hidden email]>
À: "imagej" <[hidden email]>
Envoyé: Samedi 9 Novembre 2019 14:43:11
Objet: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Philippe,

I don't understand the " alternatively create a picture for each of your file". Could you make it more easily understanding?

Regards,
Yongqiang


-----Original Message-----
From: CARL Philippe (LBP) <[hidden email]>
Sent: 09 November 2019 13:32
To: [hidden email]
Subject: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Yongqiang,
For your question about having 200 images, you can have two choices.
So either create a stack of pictures (if think this is the best option) or alternatively create a picture for each of your file.
Please have as well a look to the answer of Stein.
I didn't know about the Import -> Text Image... feature he reported and the choice between creating a 8 or 32 bit depends whether you want to create a final picture where the values are only relative (8 Bit) or absolute (i.e. equal to your float input data for the 32 bit).
At last given that your request is very easy and quite fun, if you don't mind I could use it as prototypical example to teach my daughter how to program.
Thus in the case you want to acknowledge my proposal, just send me 2 of your .csv file and I will send you the needed macro (probably by tomorrow and for sure) before tuesday.
Take care and have a nice week-end.
My best regards,
Philippe

----- Mail original -----
De: "Yongqiang Chen" <[hidden email]>
À: "imagej" <[hidden email]>
Envoyé: Samedi 9 Novembre 2019 11:15:42
Objet: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Philippe,

Can the setPix(x,y) be used on a series of images? Because the x and y are two dimensional. If there are 200 images. I wonder that how to operate the setPix(x,y) in "z" direction.

Best Regards,
Yongqiang

-----Original Message-----
From: CARL Philippe (LBP) <[hidden email]>
Sent: 08 November 2019 22:14
To: [hidden email]
Subject: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Kumar,
What you are looking for can easily be done by means of a small macro.
I would create a 309 x 826 pixels 8 bit picture setting by means of the setPixel method the lowest of your value to 0 and the highest to 255.
And to open the .csv file use File.openAsString on which result you apply the split method to extract the data for each pixel.
My best regards,
Philippe


Philippe CARL
Laboratoire de Bioimagerie et Pathologies UMR 7021 CNRS - Université de Strasbourg Faculté de Pharmacie
74 route du Rhin
67401 ILLKIRCH
Tel : +33(0)3 68 85 41 84

----- Mail original -----
De: "kumard" <[hidden email]>
À: "imagej" <[hidden email]>
Envoyé: Vendredi 8 Novembre 2019 22:25:05
Objet: intensity at each pixel in CSV format to open as greyscale image in imageJ

I have Optical coherence tomography (OCT) scan data in the form of intensity value for each pixel in an array of 309 x 826. I want to convert that data in the form of a greyscale image (min intensity: -22.3516 and Max intensity:
52.6367), say <0 dark grey but 0-10, 10-20,30-40 and >40 in the order of lighter grey to white and quantify each increase in the form of % and pixels. Thanks in advance for answering and helping out.



--
Sent from: http://imagej.1557.x6.nabble.com/

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

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

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

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

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

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

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

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

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

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

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

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

Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Yongqiang Chen
Dear Philippe,

Thank you very much for the so detailed instruction.
Enjoy the weekend~

All the best.

Regards,
Yongqiang

-----Original Message-----
From: CARL Philippe (LBP) <[hidden email]>
Sent: 09 November 2019 15:52
To: [hidden email]
Subject: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Yongqiang,

> Instead, using "nSlices" directly can return the slice number in the stack.

You are fully right: I forget about "nSlices" and it is indeed way more ad hoc than the solution I proposed!

> I tried the method. But it did not work in this case.

Nevertheless the solution I proposed HAS to work:

With nSlices you can do right away:
for(i = 1; i <= nSlices; i++)
{.....

With the solution I proposed you just do:
Stack.getDimensions(bob, john, peter, lenna); for(i = 1; i <= lenna; i++) {.....

but both have to work!

My best regards,

Philippe

----- Mail original -----
De: "Yongqiang Chen" <[hidden email]>
À: "imagej" <[hidden email]>
Envoyé: Samedi 9 Novembre 2019 16:26:11
Objet: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Hi Philippe,

I tried the method. But it did not work in this case. Instead, using "nSlices" directly can return the slice number in the stack.

Best Regards,
Yongqiang

-----Original Message-----
From: CARL Philippe (LBP) <[hidden email]>
Sent: 09 November 2019 14:58
To: [hidden email]
Subject: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Yongqiang,
Launching the method "Stack.getDimensions(width, height, channels, slices, frames)"
will return you 5 parameters or results:
- width   which is the width  of your given picture
- height  which is the height of your given picture
- channel which is the number of channels it has, which is probably 1 for you.
- slices  which is the number of channels it has, which is the information you are looking for
- frames  which is the number of time frames it has.
Also if you are sure frames is 1 in your case or don't use it's value, you can alternatively launch:
"Stack.getDimensions(width, height, channels, slices)"
And you can even launch
"Stack.getDimensions(bob  , john  , peter   , lenna)"
lenna being then the slice size you are looking for.
My best regards,
Philippe

----- Mail original -----
De: "Yongqiang Chen" <[hidden email]>
À: "imagej" <[hidden email]>
Envoyé: Samedi 9 Novembre 2019 15:47:25
Objet: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Philippe,

Thank you so much for the information.
But I check the macro on the website. It says that " Stack.getDimensions(width, height, channels, slices, frames) Returns the dimensions of the current image". It means that it will return the dimension of the current image. So this dimension is only for a single slice. It may not work for the slice number of the stack.

Best Regards,
Yongqiang

-----Original Message-----
From: CARL Philippe (LBP) <[hidden email]>
Sent: 09 November 2019 14:40
To: [hidden email]
Subject: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Yongqiang,
I can't really help you in Python since I only program in macro (for quick and dirty codes) and directly move over to Java in the case I need to more fancy or complicated things.
And for the macro programming, all the functions are reported here:
https://imagej.nih.gov/ij/developer/macro/functions.html
For your question:
"I didn’t find a Macro that can directly tell the depth of an unknown stack"
the answer is:
Stack.getDimensions(width, height, channels, slices, frames) Good luck and have a nice week-end.
My best regards,
Philippe

----- Mail original -----
De: "Yongqiang Chen" <[hidden email]>
À: "imagej" <[hidden email]>
Envoyé: Samedi 9 Novembre 2019 15:31:50
Objet: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Philippe,

Thank you for your patient detailed explanation. I think I got your point. I already tried the method and it works.

But it seems not too perfect in the imageJ. I didn’t find a Macro that can directly tell the depth of an unknown stack (how many slices in the stack). If there's a method that can return the size of slack, it would be nicer. So I am trying to use python to operate the pixel (don't know java...).

Thank you and have a good weekend.

Best Regards,
Yongqiang

-----Original Message-----
From: CARL Philippe (LBP) <[hidden email]>
Sent: 09 November 2019 14:18
To: [hidden email]
Subject: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Yongqiang;
A picture is a representation of two dimensionnal data which are either in 8 bit integer (i.e. between 0 and 255 = 2^8 - 1) or 16 bit (between 0 and 2^16 - 1) or 32 bit (float data).
So you can set the data of your picture with the setPixel(x, y, value) macro method and read them with the getPixel(x, y) method.
Thus if you have 200 .csv files (containing each the x and y data for only one picture) one option is to create a single picture for each of your .csv file (which is what I referenced by "alternatively create a picture for each of your file").
But what I think is much better is to simply create a stack picture with newImage(title, type, width, height, depth) and in your case depth will be equal to 200.
Then navigate from a stack slice to another with setSlice(n), FYI the n value of the setSlice(n) method is the "z" value of your previous question.
You can even push things further by setting a given slice label to the name of the corresponding source .csv file with run("Set Label...", "label=" + yourCSVFileName); Hoping that I helped you to move further, please do not hesitate to contact me for further questions.
My best regards,
Philippe

----- Mail original -----
De: "Yongqiang Chen" <[hidden email]>
À: "imagej" <[hidden email]>
Envoyé: Samedi 9 Novembre 2019 14:43:11
Objet: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Philippe,

I don't understand the " alternatively create a picture for each of your file". Could you make it more easily understanding?

Regards,
Yongqiang


-----Original Message-----
From: CARL Philippe (LBP) <[hidden email]>
Sent: 09 November 2019 13:32
To: [hidden email]
Subject: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Yongqiang,
For your question about having 200 images, you can have two choices.
So either create a stack of pictures (if think this is the best option) or alternatively create a picture for each of your file.
Please have as well a look to the answer of Stein.
I didn't know about the Import -> Text Image... feature he reported and the choice between creating a 8 or 32 bit depends whether you want to create a final picture where the values are only relative (8 Bit) or absolute (i.e. equal to your float input data for the 32 bit).
At last given that your request is very easy and quite fun, if you don't mind I could use it as prototypical example to teach my daughter how to program.
Thus in the case you want to acknowledge my proposal, just send me 2 of your .csv file and I will send you the needed macro (probably by tomorrow and for sure) before tuesday.
Take care and have a nice week-end.
My best regards,
Philippe

----- Mail original -----
De: "Yongqiang Chen" <[hidden email]>
À: "imagej" <[hidden email]>
Envoyé: Samedi 9 Novembre 2019 11:15:42
Objet: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Philippe,

Can the setPix(x,y) be used on a series of images? Because the x and y are two dimensional. If there are 200 images. I wonder that how to operate the setPix(x,y) in "z" direction.

Best Regards,
Yongqiang

-----Original Message-----
From: CARL Philippe (LBP) <[hidden email]>
Sent: 08 November 2019 22:14
To: [hidden email]
Subject: Re: intensity at each pixel in CSV format to open as greyscale image in imageJ

Dear Kumar,
What you are looking for can easily be done by means of a small macro.
I would create a 309 x 826 pixels 8 bit picture setting by means of the setPixel method the lowest of your value to 0 and the highest to 255.
And to open the .csv file use File.openAsString on which result you apply the split method to extract the data for each pixel.
My best regards,
Philippe


Philippe CARL
Laboratoire de Bioimagerie et Pathologies UMR 7021 CNRS - Université de Strasbourg Faculté de Pharmacie
74 route du Rhin
67401 ILLKIRCH
Tel : +33(0)3 68 85 41 84

----- Mail original -----
De: "kumard" <[hidden email]>
À: "imagej" <[hidden email]>
Envoyé: Vendredi 8 Novembre 2019 22:25:05
Objet: intensity at each pixel in CSV format to open as greyscale image in imageJ

I have Optical coherence tomography (OCT) scan data in the form of intensity value for each pixel in an array of 309 x 826. I want to convert that data in the form of a greyscale image (min intensity: -22.3516 and Max intensity:
52.6367), say <0 dark grey but 0-10, 10-20,30-40 and >40 in the order of lighter grey to white and quantify each increase in the form of % and pixels. Thanks in advance for answering and helping out.



--
Sent from: http://imagej.1557.x6.nabble.com/

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

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

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

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

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

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

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

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

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

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

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

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

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