Login  Register

Re: save image as CSV?

Posted by Christophe CHAMOT on Nov 19, 2007; 6:20pm
URL: http://imagej.273.s1.nabble.com/save-image-as-CSV-tp3697977p3697978.html

Stanislav Vitha a écrit :

> Hi,
> is there a way to save the image as comma separated value (ideally with
> the option of including/not including a header in the first line)?  
> The images are grayscale, 8, 16 or 32 bit.
> Something like this:  The coordinates (X,Y) and pixel values (Ch1) should
> be in the calibrated units.
>
> X,Y,Ch1
> 0.000,0.000,125000.000
> 1.000,0.000,130000.000
> 2.000,0.000,140000.000
> 3.000,0.000,125000.000
> 4.000,0.000,135000.000
> 5.000,0.000,130000.000
> 6.000,0.000,120000.000
> 7.000,0.000,140000.000
> 8.000,0.000,140000.000
> 9.000,0.000,140000.000
> ...
> ...
> 152.000,377.000,95000.000
>
> Thanks!
>
> Stan Vitha
>
>
> Dr. Stanislav Vitha      [hidden email]
> Microscopy and Imaging Center
> Texas A&M University
> BSBW 119
> College Station, TX 77843-2257
>
>
>  
Hello,

I haven't seen any response for this mail.
A simple macro (brutal force) :
---------snip-------------------
row=0;
w=getWidth();
h=getHeight();
for(x=0;x<=w;x++){
    for(y=0;y<=h;y++){
        v=getPixel(x,y);
        setResult("X",row,x);
        setResult("Y",row,y);
        setResult("value",row,v);
        row++;
    }
}
updateResults();

---------snap-------------------

Copy-paste in a new macro then run. Save the Results with .csv extension ...

Cheers,

--
Christophe CHAMOT
---------------------------------------------------------------------
Plate-Forme de Recherche UMR7592
"Imageries des Processus Dynamiques
en Biologie  Cellulaire et Biologie du Développement "
Institut Jacques Monod, CNRS,  Universités Paris 6 et 7
2, place Jussieu - Tour 43
75251 Paris cedex  05
Tel: 01 44 27 47 56
fax: 01 44 27 98 57
http://www.ijm.fr/
---------------------------------------------------------------------