Hi everyone,
I'm hoping someone can help with my small problem. I've been using the trainable weka segmentation plugin to quantify some images, although havn't used it for a while since the latest update and the macro I've been using doesn't seem to do what I'm after anymore. I train with classifiers and then run this macro to get percentages of the selected classes in the image (text continues after code): // id values of each class in the classified image classLabels = newArray( 0, 64, 128, 191, 255 ); setBatchMode( true ); run("Set Measurements...", "area_fraction redirect=None decimal=3"); for( i=0; i<classLabels.length; i ++ ) { minTh = classLabels[ i ]; maxTh = classLabels[ i ]; if( i < classLabels.length - 1 ) maxTh = classLabels[ i+1 ] -1; else // last value is assumed to be 255 { minTh = classLabels[ i-1 ] +1; maxTh = classLabels[ i ]; } selectWindow("Classified image"); run("Duplicate...", "title=[to-be-thresholded]"); selectWindow("to-be-thresholded"); setThreshold( minTh, maxTh ); run("Convert to Mask"); run("Measure"); close(); } Although now the problem is the result comes back as 100% for class 1 and 0% for the rest of the classes. I'm not proficient at all at scripting, so I'd really appreciate if anyone could debug my problem. Thanks before hand. Regards, Patrick -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hello Patrick,
Since the last version of the Trainable Weka Segmentation, the labels are set to more meaningful values: 0, 1, 2... So your macro should work if you change the first line of code to: classLabels = newArray( 0, 1, 2, 3, 4 ); Let me know if you have more problems. ignacio On Thu, May 1, 2014 at 3:10 AM, Mr Patrick Fortuna < [hidden email]> wrote: > Hi everyone, > > > I'm hoping someone can help with my small problem. I've been using the > trainable weka segmentation plugin to quantify some images, although havn't > used it for a while since the latest update and the macro I've been using > doesn't seem to do what I'm after anymore. I train with classifiers and > then run this macro to get percentages of the selected classes in the image > (text continues after code): > > > // id values of each class in the classified image > > classLabels = newArray( 0, 64, 128, 191, 255 ); > > > > setBatchMode( true ); > > run("Set Measurements...", "area_fraction redirect=None decimal=3"); > > > > for( i=0; i<classLabels.length; i ++ ) > > { > > minTh = classLabels[ i ]; > > maxTh = classLabels[ i ]; > > if( i < classLabels.length - 1 ) > > maxTh = classLabels[ i+1 ] -1; > > else // last value is assumed to be 255 > > { > > minTh = classLabels[ i-1 ] +1; > > maxTh = classLabels[ i ]; > > } > > selectWindow("Classified image"); > > run("Duplicate...", "title=[to-be-thresholded]"); > > selectWindow("to-be-thresholded"); > > setThreshold( minTh, maxTh ); > > run("Convert to Mask"); > > run("Measure"); > > close(); > > } > > > > Although now the problem is the result comes back as 100% for class 1 and > 0% for the rest of the classes. > > I'm not proficient at all at scripting, so I'd really appreciate if anyone > could debug my problem. > > Thanks before hand. > > > Regards, > > Patrick > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- Ignacio Arganda-Carreras, Ph.D. Seung's lab, 46-5065 Department of Brain and Cognitive Sciences Massachusetts Institute of Technology 43 Vassar St. Cambridge, MA 02139 USA Phone: (001) 617-324-3747 Website: http://bioweb.cnb.csic.es/~iarganda/index_EN.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |