setBatchMode(false);
ori = getTitle();
//Selecting nothing just in case
run("Select None");
setTool(4);                     //Line Tool
message= "Line Selection Required\n Please create a break line";
waitForUser(message);
getLine(x1, y1, x2, y2, lineWidth);
dx = x2-x1; // change in x
dy = y2-y1; // change in y
if (dx == 0) {
slope = 1; // can't divide by 0
} else {
slope = dy / dx;
}
intercept = slope * x1 - y1;
hgt = getHeight();
wth = getWidth();
xAty0point = abs((0-intercept) / slope); // -y = 0
xAtyMaxpoint =  ((hgt+intercept) / slope); // -y = hgt
makePolygon(xAty0point, 0, xAtyMaxpoint, hgt, wth, hgt, wth, 0);

roiManager("Add");
run("Make Inverse");
roiManager("Add");
run("Make Inverse");

// ROI[0] should be right side of line
// ROI[1] should be left side
run("Select None");
run("Duplicate...", "title=[for mask]");
roiManager("Select", 1);
setForegroundColor(0, 0, 255);
run("Fill", "slice");
//run("Threshold...");
// Color Thresholder 1.48v
// Autogenerated macro, single images only!
min=newArray(3);
max=newArray(3);
filter=newArray(3);
a=getTitle();
run("HSB Stack");
run("Convert Stack to Images");
selectWindow("Hue");
rename("0");
selectWindow("Saturation");
rename("1");
selectWindow("Brightness");
rename("2");
min[0]=0;
max[0]=75;
filter[0]="pass";
min[1]=0;
max[1]=255;
filter[1]="pass";
min[2]=0;
max[2]=150;
filter[2]="pass";
for (i=0;i<3;i++){
  selectWindow(""+i);
  setThreshold(min[i], max[i]);
  run("Convert to Mask");
  if (filter[i]=="stop")  run("Invert");
}
imageCalculator("AND create", "0","1");
imageCalculator("AND create", "Result of 0","2");
for (i=0;i<3;i++){
  selectWindow(""+i);
  close();
}
selectWindow("Result of 0");
close();
selectWindow("Result of Result of 0");
rename(a);
// Colour Thresholding-------------
run("Create Selection");
close();
selectWindow(ori);
run("Restore Selection");
run("Measure");
run("Select None");
run("Duplicate...", "title=[for mask]");
roiManager("Select", 0);
setForegroundColor(0, 0, 255);
run("Fill", "slice");
//run("Threshold...");
// Color Thresholder 1.48v
// Autogenerated macro, single images only!
min=newArray(3);
max=newArray(3);
filter=newArray(3);
a=getTitle();
run("HSB Stack");
run("Convert Stack to Images");
selectWindow("Hue");
rename("0");
selectWindow("Saturation");
rename("1");
selectWindow("Brightness");
rename("2");
min[0]=0;
max[0]=75;
filter[0]="pass";
min[1]=0;
max[1]=255;
filter[1]="pass";
min[2]=0;
max[2]=150;
filter[2]="pass";
for (i=0;i<3;i++){
  selectWindow(""+i);
  setThreshold(min[i], max[i]);
  run("Convert to Mask");
  if (filter[i]=="stop")  run("Invert");
}
imageCalculator("AND create", "0","1");
imageCalculator("AND create", "Result of 0","2");
for (i=0;i<3;i++){
  selectWindow(""+i);
  close();
}
selectWindow("Result of 0");
close();
selectWindow("Result of Result of 0");
rename(a);
// Colour Thresholding-------------
run("Create Selection");
close();
selectWindow(ori);
run("Restore Selection");
run("Measure");
selectWindow("ROI Manager");
run("Close");




--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html