package segmentation;

import comparison.SaveHabitualData;

import noise.IsolatedPixelsRemoval_;
import noise.RegionRemoval_;
import filter.Average;
import ij.ImagePlus;
import ij.gui.NewImage;
import ij.process.ImageProcessor;
import representation.Dilatation;
import representation.Moore;
import representation.SlantVertiPro;
//import sizeNormalization.DeleteWhiteSpaces;
import sizeNormalization.ResizeImage;
import histogram.HorizontalHistogram;
import GUI.FileChooser;
import GUI.internalFrame;
import GUI.mainWindow;
import thresholding.Entropy_Threshold;
import thresholding.OtsuThresholding_;
import segmentation.*;

public class HabitsData {
	
	private ImageProcessor ip;
	private ImagePlus imp, impOtsu;
	private int numberResult;
	
	private HorizontalHistogram horizHist;
	private Average averageFilter;
	private Entropy_Threshold entropy;
	private Line4 lineSeg4;
	private Dilatation dilatation;
	private IsolatedPixelsRemoval_ ipr;
	private RegionRemoval_ rr;
	private Separation sep;
	private ResizeImage resize;
	private OtsuThresholding_ otsu;
//	private DeleteWhiteSpaces deleteWhiteSpaces;
	private SlantVertiPro slant;
	private SaveHabitualData habitData;
	private BaseLines baselines;
	private Moore moore;
	
	public HabitsData(ImagePlus imp, ImageProcessor ip, int numberResult, ImagePlus impOtsu) {
		this.ip = ip;
		this.imp = imp;
		this.numberResult = numberResult;
		this.impOtsu = impOtsu;
	}
	
/*	public ImagePlus run(){
		//NAJPRV UROBIME SEPARACIU RIADKOV

		//otsu algorithm
		otsu = new OtsuThresholding_(imp.getTitle(), numberResult, false); 
		otsu.run(ip.convertToByte(false));
		otsu.setup("about", imp);
		imp = otsu.getImg();
		ip = otsu.getIp();	
		impOtsu = otsu.getImg();

				//erode
		erode = new Erode(imp, ip, numberResult, false);
		erode.run();
		imp = erode.getImg();
		ip = erode.getIp();	
		impOtsu = erode.getImg();

				//delete white spaces
		deleteWhiteSpaces = new DeleteWhiteSpaces(numberResult);
		deleteWhiteSpaces.run(imp, image);
		imp = deleteWhiteSpaces.getImg();
		ip = deleteWhiteSpaces.getIp();
		impOtsu = imp;

		//docasne vyhodene

		//dilatation
		dilatation = new Dilatation(imp, ip, numberResult, false);
		dilatation.run();
		imp = dilatation.getImg();
		ip = dilatation.getIp();	

		//projection profile of chunks
		horizHist = new HorizontalHistogram(imp, ip, false, numberResult, false);
		imp = horizHist.getImg();
		ip = horizHist.getIp();

		//average filter
		averageFilter = new Average(imp, ip, numberResult, false);
		//	averageFilter.run2();
		averageFilter.run3();
		imp = averageFilter.getImg();
		ip = averageFilter.getIp();

		//thresholding

		///entropy
		entropy = new Entropy_Threshold(imp.getTitle(), numberResult, false); 
		entropy.setup("assa", imp);
		entropy.run(ip.convertToByte(false));
		imp = entropy.getImg();
		ip = entropy.getIp();

				//erode
		erode = new Erode(imp, ip, numberResult, true);
		erode.run();
		imp = erode.getImg();
		ip = erode.getIp();	

		//Region removal
		rr = new RegionRemoval_(imp, ip, numberResult, false);
		rr.run();
		imp = rr.getImg();
		ip = rr.getIp();

		//Isolated Pixels Removal
		ipr = new IsolatedPixelsRemoval_(imp, ip, numberResult, false);
		ipr.run();
		imp = ipr.getImg();
		ip = ipr.getIp();

		//line segmentation
		lineSeg4 = new Line4(imp, ip, impOtsu, numberResult, false);
		lineSeg4.run();
		imp = lineSeg4.getImg();
		ip = lineSeg4.getIp();

		//line separation
		sep = new Separation(imp, ip, impOtsu, numberResult, true, true);
		sep.run();
		imp = sep.getImg();
		ip = sep.getIp();
		ImagePlus impSeparLines = imp;

		//ODSTRANENIE SKLONU
		//slant correction
		slant = new SlantVertiPro(imp, ip, numberResult, true, true);
		imp = slant.getImg();
		ip = slant.getIp();	
		impSeparLines = imp;
		
		/////words and segments of words and graphemes
		moore = new Moore(impSeparLines, imp, ip, numberResult, true);
		moore.run(true);
		moore.separateWords(false, true);
		//imp = moore.getImg();
		//ip = moore.getIp();
		

		//DALSI KROK - BASELINES

		//horizontal projection profile
		horizHist = new HorizontalHistogram(imp, ip, true, numberResult, false);
		imp = horizHist.getImg();
		ip = horizHist.getIp();

		//average filter
		averageFilter = new Average(imp, ip, numberResult, false);
		averageFilter.run2();
		imp = averageFilter.getImg();
		ip = averageFilter.getIp();

		///entropy
		entropy = new Entropy_Threshold(imp.getTitle(), numberResult, false); 
		entropy.setup("assa", imp);
		entropy.run(ip.convertToByte(false));
		imp = entropy.getImg();
		ip = entropy.getIp();

		//Region removal
		rr = new RegionRemoval_(imp, ip, numberResult, false);
		rr.run();
		imp = rr.getImg();
		ip = rr.getIp();

		//Isolated Pixels Removal
		ipr = new IsolatedPixelsRemoval_(imp, ip, numberResult, false);
		ipr.run();
		imp = ipr.getImg();
		ip = ipr.getIp();		

		///baselines
		baselines = new BaseLines(imp, ip,  impSeparLines, numberResult, true);
		baselines.run();
		imp = baselines.getImg();
		ip = baselines.getIp();				

		//SAVE DATA
		habitData = new SaveHabitualData(numberResult);
		habitData.run();		

		return imp;
	}	*/

}
