Posted by
Yongqiang Chen on
Nov 09, 2019; 3:55pm
URL: http://imagej.273.s1.nabble.com/intensity-at-each-pixel-in-CSV-format-to-open-as-greyscale-image-in-imageJ-tp5022632p5022648.html
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.htmlFor 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