save image as CSV?

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

save image as CSV?

Stanislav Vitha
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
Reply | Threaded
Open this post in threaded view
|

Re: save image as CSV?

Christophe CHAMOT
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/
---------------------------------------------------------------------
Reply | Threaded
Open this post in threaded view
|

Re: save image as CSV?

Stanislav Vitha
Dear Christophe,
Thank you so much!

Stan

At 12:20 PM 11/19/2007, you wrote:

>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/
>---------------------------------------------------------------------

Dr. Stanislav Vitha      [hidden email]
Microscopy and Imaging Center
Texas A&M University
BSBW 119
College Station, TX 77843-2257

tel: 979-845-1129 (main desk)
tel: 979-845-1607 (direct link)
fax: 979-847-8933
Reply | Threaded
Open this post in threaded view
|

Re: save image as CSV?

rm_simons
Hi Christophe,

A good solution, but there's an error in the 'for' statements: the use of <= will result in an extra row and column of '0' values being added to the list, I think you meant to use <
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();

There's also the option to output as a tab delimited text image through: File > Save As > Text Image...
called by:
saveAs("Text Image", "C:\\Data\\Your_file.txt");

Rich