User Tools

Site Tools


blogtng:2010-07-03:trainable_segmentation

Trainable Segmentation

A new Fiji plugin called "Trainable Segmentation" was created during the Fiji Hackathon and also further upgraded since last March, by the effort of Verena Kaynig, Ignacio Arganda-Carreras and Albert Cardona. This is quite handy if you want to train computer to let it do segmentation automatically, as it is possible to save trained data and re-use it.

Ignacio modified the code so that it could be accessed as library. Here is a sample methods of accessing the plugin from another plugin. Path to the data is set in the first method, and the second method receives ImagePlus instance (image or stack) as argument and outputs segmented image/stack.

	private static String fullpathdata = "ttt";

	public static void setDatapath(String fullpath){
		fullpathdata = fullpath;
		IJ.log("Loading data from " + fullpathdata + "...");
	}

	public static ImagePlus core(ImagePlus imp){

		ImageStack stack = imp.getStack();

		ImagePlus imptemp = new ImagePlus("training slice", new ByteProcessor(imp.getWidth(), imp.getHeight()));
		ImageProcessor ipc = imptemp.getProcessor();// = imp.getProcessor().duplicate();		
		String fullpath;
		fullpath = fullpathdata;

		ipc = stack.getProcessor(1).duplicate();
		//using Ignacio's update
		Trainable_Segmentation seg = new Trainable_Segmentation(new ImagePlus("temp", ipc));
		//"Load Data" button
		seg.loadTrainingData(fullpath);
		//"Train classifier" button
		try{
			seg.trainClassifier();
		}catch(Exception e){
			e.printStackTrace();
		}
		//"Apply Classifier" button
		ImagePlus binimp = seg.applyClassifierToTestImage(imp);
				
		return binimp;
		
	}
blogtng/2010-07-03/trainable_segmentation.txt · Last modified: 2016/05/24 12:46 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki