weird problems
Posted by Martin du Saire on Aug 15, 2006; 10:45pm
URL: http://imagej.273.s1.nabble.com/weird-problems-tp3701838.html
Hi,
1) I think ij 1.37n doesn't record starts when running the particle
analyzer, at least it doesn't display them in the Results table.
2) Either there is a BatchMode problem with 1.37h, m, and n, or my
programming stinks: When running the following macro in BatchMode,
ImageJ opens a blank image with the name of the input image and then
hangs. I have to close ImageJ to do anything else. If I comment out
line 137: close(); Everything "works", except when I run the macro
on a entire folder I eventually run out of memory...
Assuming this is not just the result of poor programming on my part,
does anyone have any old versions of ij.jar I could use?
3) Not to whine or anything, but every once in a while, when I try
to run a macro from the Plugins drop-down menu I get what appears to
be the plugin editor.
Over and out.
M
macro "_ApHue_1.0" {
var version = "AH_1.0";
// Clear old Results and Log
if (isOpen("Log") == 1) {
selectWindow("Log");
run("Close");
}
run("Clear Results");
Dialog.create("ApHue_1.0");
Dialog.addCheckbox("Batch mode", false);
Dialog.addCheckbox("Single image", true);
Dialog.show();
batchOn = Dialog.getCheckbox();
doSingleImage = Dialog.getCheckbox();
setBatchMode(batchOn);
processTimeTotal = getTime();
processTime = processTimeTotal;
// ***************** Hardcoded values ****************
imCount = 0;
hueTh = 52;
blurRadius = 5;
// ***************************************************
if (doSingleImage == true) {
fileDir = getDirectory("image");
path = fileDir;
imName = getTitle();
selectImage(imName);
datetime=substring(getTitle(),9,24);
baseName = substring(imName,0,lengthOf(imName) - 4);
HCount = hueThreshold(blurRadius, imName, baseName);
fMax = 1;
imCount = 1;
datetime=substring(datetime,0,8)+substring(datetime,9,15); //
Output datetime in MySQL friendly format
print(datetime+","+HCount);
selectImage(imName);
close();
} else {
fileDir = getDirectory("Choose a directory to process");
path = fileDir;
fileList = getFileList(fileDir);
fMax = fileList.length;
for (f=0; f<fMax; f++) {
if (startsWith(fileList[f],"snap") &
endsWith(fileList[f],".jpg") & (lengthOf(fileList[f]) == 28)) { //
Only process "snap"shots and
imagePath =
fileDir+fileList[f]; // ".jpg" images
open(imagePath);
imCount++;
imName = getTitle();
selectImage(imName);
datetime=substring(getTitle(),9,24);
baseName = substring(imName,0,lengthOf(imName) - 4);
HCount = hueThreshold(blurRadius, imName, baseName);
datetime=substring(datetime,0,8)+substring(datetime,9,15);
// Output datetime in MySQL friendly format
print(datetime+","+HCount);
selectImage(imName);
close();
}
}
}
if (batchOn == true) setBatchMode(false);
selectWindow("Log");
outFile = fileDir+"Log"+substring(datetime,0,8)+version+".txt";
print(outFile);
save(outFile);
processTimeTotal = (getTime() - processTime) * 0.001;
print("Total processing time (s): "+processTimeTotal);
print("Number of images processed: "+imCount);
} //******************* End of main *********************
function hueThreshold(fblurRadius, inName, bName) {
//print("hueThreshold");
run("Duplicate...", "title=imageCopy");
run("HSB Stack Splitter");
selectImage('imageCopy (saturation)');
close();
selectImage('imageCopy (brightness)');
close();
selectImage('imageCopy (hue)');
run("Gaussian Blur...", "radius="+fblurRadius);
setThreshold(0, hueTh);
run("Make Binary", "thresholded remaining black");
run("Analyze Particles...", "size=0-Infinity circularity=0.00-1.00
show=Outlines clear");
hueBlobOutlines = getTitle();
run("RGB Color");
imageCalculator("AND create", hueBlobOutlines, inName);
outImage = fileDir+bName+version+".jpg";
saveAs("jpeg", outImage);
close();
selectImage(hueBlobOutlines);
close();
if (nResults > 0) {
selectImage('imageCopy (hue)');
close();
}
return nResults;
}