Automating histogram values output

Hello,

I’ve been looking around but have not found the answer I seek. Is there a way to automatically export strings of 1D histogram values to a results table as part of a macro? I want to compare changes in relative histogram dimensions between many images and manually copying data from thousands of images is too time-consuming.

Best, Surace

Hi Surace,
I’m not sure my answer will fully correspond to what you are looking for but you will find below a quick example about the function " File.append(string, path) "

Feel free to contact me if it’s not clear.

Cheers,

Romain

/////////////////////////////////////////////////// Macro START
/* 
 *  make a line profile at different position in the image and store each profile as a row in a defined file
 *  
 */

////////////////////////////////////// define a file to save things
savingPath = getDirectory("");
fileName = "outputFile.txt";
f = savingPath + fileName;

////////////////////////////////////// to erase existing file (if needed)
if ( File.exists(f) ){
	File.delete(f);
}
////////////////////////////////////// open an image and gets some infos about it
run("Clown (14K)");
getDimensions(widthImage, heightImage, channels, slices, frames);
title = getTitle;

////////////////////////////////////// make a line profile at different position in the image and store the value 
step = 10 ; 
for ( lineIndex = 0 ; lineIndex < heightImage ; lineIndex+=step){
	makeLine(0, lineIndex, widthImage, lineIndex);	// make a line
	values = getProfile();						// get values
	////////////////////////////////////////////////// convert array to string, defining a splitter 
	columnSplitter 	= "," ;					// here you specify your column splitter
	currentRow = title+columnSplitter+lineIndex;	// initialize with some infos	
	for(columnIndex = 0 ; columnIndex < lengthOf(values) ; columnIndex++){
		currentRow = currentRow  + columnSplitter + values[columnIndex] ;
	}
	////////////////////////////////////////////////// Append the string to the file "f"	
	File.append(currentRow, f);
}
showMessage("Job done");
/////////////////////////////////////////////////// Macro END
1 Like