Hi everybody, I´m trying to make a macro to separete diferent parts of an image using Color thershold, the macro works fine, but in some image when I run the command run("Convert to mask"), it suddendly change the selection and make the mask from the part of the image that I don´t want, I have try to finish the macro in that point, run the command run("make inverese"), and it works fine, but if I add to the macro, the programa doesn´t make any and works in the wrong way again. Any idea why is this happening?
Here is the code...I have the problem at the end, but in some image only(doing the same manual, works fine). Thanks. input = "....."; output = "....."; //setBatchMode(true); //apertura automatica list = getFileList(input); for (numero = 0; numero < list.length; numero++){ //for (numero = 0; numero < 2; numero++){ open(input+list[numero]); //fina apertura automatica //open(input+"Asfalt1c.tif"); nombre = getInfo("image.filename"); longitud= lengthOf(nombre) - 4; b=substring(nombre,0,longitud); //Creo directorio File.makeDirectory("D:\\CTCON\\FIJI\\salidaprueba\\"+b+"\\"); directorio=output+b+"\\"; rutaimagen = directorio+b + "cont.jpg"; rutanegro=directorio+b + "BN.jpg"; rutasuma= output+b+ "suma"; rutaresultado=output+b + "result"; //showMessage(b); saveAs("tiff", directorio+b+"original.tif"); //Mask1 (0-70) open(input+list[numero]); run("Color Threshold..."); // Color Thresholder 1.49t // 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]=116; filter[0]="pass"; min[1]=0; max[1]=255; filter[1]="pass"; min[2]=0; max[2]=70; 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("8-bit"); run("Create Selection"); run("Convert to Mask"); run("Set Scale...", "distance=1361 known=73 pixel=1 unit=mm"); run("Erode"); saveAs("Jpeg", directorio+b+"Mask1.jpg"); run("Analyze Particles...", " show=Outlines display exclude include summarize"); saveAs("Jpeg", directorio+b+"Mask1 outline.jpg"); selectWindow("Results"); saveAs("Text", rutaresultado+"Mask1.xls"); run("Close"); selectWindow("Summary"); saveAs("Text", rutasuma+"Mask1.xls"); selectWindow(b+"suma"+"Mask1.xls"); run("Close"); run("Close All"); //mask2 (70-255) open(input+list[numero]); run("Color Threshold..."); // Color Thresholder 1.49t // 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]=116; filter[0]="pass"; min[1]=0; max[1]=255; filter[1]="pass"; min[2]=70; max[2]=255; 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("8-bit"); run("Create Selection"); showMessage("para"); run("Make Inverse"); showMessage("para2"); run("Convert to Mask"); run("Create Selection"); run("Make Inverse"); run("Convert to Mask"); }; setBatchMode(false); |
Free forum by Nabble | Edit this page |