Login  Register

Re: save image as CSV?

Posted by rm_simons on Apr 14, 2016; 3:14pm
URL: http://imagej.273.s1.nabble.com/save-image-as-CSV-tp3697977p5016137.html

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