package cz.vutbr.feec.imageprocessing.op.segmentation.watershed;

import ij.ImagePlus;
import ij.process.ImageConverter;


//this class was used for testing in eclipse environment
public class Main {
	/*
	 * http://theba.sourceforge.net/javadoc-1.0.4/dir_bb918a79682367ca7c61102bb39cad2e.html
	 * http://dev.imagejdev.org/trac/imglib/browser/imglib-algorithms/src/main/java/mpicbg/imglib/algorithm/labeling?rev=08bf8e632ee60f31b41256707b6dad6411ac7ec4
	 */
	public static void main(String[] args) {
		WatershedAlgorithm wa = new WatershedAlgorithm();
		// show windows with steps
		wa.debug(false);
		
		//ImagePlus inputImage = new ImagePlus(".\\src\\samples\\testBMP07.bmp");
		ImagePlus inputImage = new ImagePlus("data/1.png");
		//ImagePlus inputImage = new ImagePlus(".\\src\\samples\\pepper500k.jpg");
		
		// convert image to RGB in case that image is not RGB 
		//ImageConverter ic = new ImageConverter(inputImage);
		//ic.convertToRGB();
		
		//inputImage.setProcessor(inputImage.getProcessor().resize(400));
		//inputImage.show();
		
		//convertModel 0 weight RGB, model 1 does not weight RGB during computing gray
		RgbToGSModel convertModel = RgbToGSModel.RGB_TO_GS;
		//connectivityModel 0 means 8-point neighborhood; 1 means 4-point neighborhood
		ConnectivityModels connectivityModel = ConnectivityModels.C8;
		//threshold for connecting small regions to neighboring regions in promile
		int smallRegionThr = 3;
		//threshold for merging; compared with (R1-R2)*(G1-G2)*(B1-B2), where indexes 1 and 2 are two merging regions
		int mergingThr = 5000;
		//true if wsheds should be assigned to neighboring regions; now is always true
		boolean wsheds = true;
		ImagePlus res = wa.doWork(inputImage, convertModel, connectivityModel, smallRegionThr, mergingThr, wsheds);
		res.setProcessor(res.getProcessor().resize(400));
		res.show();
	}
	

}
