Snippets

Dave Mason Count thresholded pixels (https://forum.image.sc/t/macro-for-batch-saving-of-histogram-results/20153)

Created by Dave Mason
dir1 = getDirectory("Choose Source Directory ");
dir2 = getDirectory("Choose Destination Directory ");
list = getFileList(dir1);
setBatchMode(true);
//nBins = 256;

//-- open a file for output and write a header
f = File.open(dir2+File.separator+"output.txt");
print(f, "Filename\tPixels");

//-- make sure this is correct otherwise you'll be measuring the wrong thing!
setOption("BlackBackground", false);

//-- Loop the file list
for (i=0; i<list.length; i++) {
showProgress(i+1, list.length);
open(dir1+list[i]);
title=getTitle();
List.setMeasurements;
print(f, title+"\t"+d2s(List.getValue("RawIntDen")/255,0));
//-- close the current file
close(title);
}
//-- Close the output
File.close(f);

Comments (0)