private void cbTransform_SelectedIndexChanged(object sender, EventArgs e) { switch (cbTransform.Text) { case "Fourier": { transformY = new Func <Double[], Double[], Double[]>((y, args) => Transformations.FurieFunction(y)); addParameters(panelTransformParams, new string[] { }); break; } case "ForwardFurie": { transformY = new Func <Double[], Double[], Double[]>((y, args) => Transformations.ForwardFurie(y).Select(x => x.Imaginary + x.Real).ToArray()); addParameters(panelTransformParams, new string[] { }); break; } case "ReverseFurie": { transformY = new Func <Double[], Double[], Double[]>((y, args) => Transformations.ReverseFurie(y).Select(x => x.Imaginary + x.Real).ToArray()); addParameters(panelTransformParams, new string[] { }); break; } case "CombFilter": { transformY = new Func <Double[], Double[], Double[]>((y, args) => { double[] res = Transformations.CombFilter(y, args[0], (int)args[1]); return(res); }); addParameters(panelTransformParams, new string[] { "g", "M" }); break; } case "Spikes(F(x),M,Sigma)": { transformY = new Func <Double[], Double[], Double[]>((y, args) => Transformations.SpikesFunction(y, args[0], args[1])); addParameters(panelTransformParams, new string[] { "M", "sigma" }); break; } case "Shift(F(x),shift)": { transformY = new Func <Double[], Double[], Double[]>((y, args) => Transformations.ShiftFunction(y, args[0])); addParameters(panelTransformParams, new string[] { "shift" }); break; } case "RandomSpikes(x,spikes)": { transformY = new Func <Double[], Double[], Double[]>((y, args) => Transformations.RandomSpikes(y, (int)args[0], args[1])); double tmp = 0; addParameters(panelTransformParams, new string[] { "spikes", "sigma" }); break; } case "ConvolutionWithHeartBeat(x,f0,alpha,hLeft,hRight,hStep)": { transformY = new Func <Double[], Double[], Double[]>((y, args) => Transformations.ConvolutionWithHeartBeat(y, args[0], args[1], args[2], args[3], args[4], Double.Parse(tbStep.Text))); double tmp = 0; addParameters(panelTransformParams, new string[] { "f0", "alpha", "hLeft", "hRight", "hStep" }); break; } case "Zoom": { transformY = new Func <Double[], Double[], Double[]>((y, args) => y); transformWhole = new Func <double[][], double[], double[][]>((y, args) => Transformations.ZoomKnearest(y, args[0])); double tmp = 0; addParameters(panelTransformParams, new string[] { "k" }); break; } case "ZoomInterpolation": { transformY = new Func <Double[], Double[], Double[]>((y, args) => y); transformWhole = new Func <double[][], double[], double[][]>((y, args) => Transformations.ZoomInterpilation(y, args[0])); double tmp = 0; addParameters(panelTransformParams, new string[] { "k" }); break; } case "Negative": { transformY = new Func <Double[], Double[], Double[]>((y, args) => y); transformWhole = new Func <double[][], double[], double[][]>((y, args) => Transformations.Negative(y, 255)); double tmp = 0; addParameters(panelTransformParams, new string[] { }); break; } case "Gamma-correction": { transformY = new Func <Double[], Double[], Double[]>((y, args) => y); transformWhole = new Func <double[][], double[], double[][]>((y, args) => Transformations.GammaCorrection(y, args[0], args[1])); double tmp = 0; addParameters(panelTransformParams, new string[] { "C", "gamma" }); break; } case "Reascale": { transformY = new Func <Double[], Double[], Double[]>((y, args) => y); transformWhole = new Func <double[][], double[], double[][]>((y, args) => RescaleImage(y)); double tmp = 0; addParameters(panelTransformParams, new string[] { }); break; } case "Logarithmic": { transformY = new Func <Double[], Double[], Double[]>((y, args) => y); transformWhole = new Func <double[][], double[], double[][]>((y, args) => Transformations.Logarithmic(y, args[0])); double tmp = 0; addParameters(panelTransformParams, new string[] { "C" }); break; } case "Equalization": { transformY = new Func <Double[], Double[], Double[]>((y, args) => y); transformWhole = new Func <double[][], double[], double[][]>((y, args) => Histogram.HistEquilization(y, 256)); double tmp = 0; addParameters(panelTransformParams, new string[] {}); break; } case "Reduction": { transformY = new Func <Double[], Double[], Double[]>((y, args) => y); transformWhole = new Func <double[][], double[], double[][]>((y, args) => Histogram.HistReduction(y, 256)); double tmp = 0; addParameters(panelTransformParams, new string[] { }); break; } case "Recovery": { transformY = new Func <Double[], Double[], Double[]>((y, args) => y); transformWhole = new Func <double[][], double[], double[][]>((y, args) => Transformations.recovery(y, tbAuxFile.Text)); double tmp = 0; addParameters(panelTransformParams, new string[] { }); break; } case "Recovery with noize": { transformY = new Func <Double[], Double[], Double[]>((y, args) => y); transformWhole = new Func <double[][], double[], double[][]>((y, args) => Transformations.RecoveryWithNoize(y, tbAuxFile.Text, args[0])); double tmp = 0; addParameters(panelTransformParams, new string[] { "regularization" }); break; } case "Rotate": { transformY = new Func <Double[], Double[], Double[]>((y, args) => y); transformWhole = new Func <double[][], double[], double[][]>((y, args) => Transformations.Rotate(y)); double tmp = 0; addParameters(panelTransformParams, new string[] { }); break; } case "CheckGrid": { transformY = new Func <Double[], Double[], Double[]>((y, args) => y); transformWhole = new Func <double[][], double[], double[][]>((y, args) => { Transformations.CheckGrid(y[(int)args[0]]); return(y); }); double tmp = 0; addParameters(panelTransformParams, new string[] { "row" }); break; } case "CheckGridWithCrossCorrelation": { transformY = new Func <Double[], Double[], Double[]>((y, args) => y); transformWhole = new Func <double[][], double[], double[][]>((y, args) => { Transformations.CheckGridWithCross(y, (int)args[0], (int)args[1]); return(y); }); double tmp = 0; addParameters(panelTransformParams, new string[] { "row1", "row2" }); break; } case "RemoveGrid": { transformY = new Func <Double[], Double[], Double[]>((y, args) => y); transformWhole = new Func <double[][], double[], double[][]>((y, args) => Transformations.RemoveGrid(y, args[0], args[1], args[2])); double tmp = 0; addParameters(panelTransformParams, new string[] { "freq1", "freq2", "m" }); break; } case "ConturLPF": { transformY = new Func <Double[], Double[], Double[]>((y, args) => y); transformWhole = new Func <double[][], double[], double[][]>((y, args) => Transformations.ConturLPF(y, args[0], args[1], args[2])); addParameters(panelTransformParams, new string[] { "threshold", "fcut", "m" }); break; } case "Threshold": { transformY = new Func <Double[], Double[], Double[]>((y, args) => y); transformWhole = new Func <double[][], double[], double[][]>((y, args) => Transformations.ThresholdFun(y, args[0], args[1], 8)); addParameters(panelTransformParams, new string[] { "min_threshold", "max_threshold" }); break; } case "ThresholdDynamic": { transformY = new Func <Double[], Double[], Double[]>((y, args) => y); transformWhole = new Func <double[][], double[], double[][]>((y, args) => Transformations.ThresholdFunDynamic(y, (int)args[0])); addParameters(panelTransformParams, new string[] { "Windows count" }); break; } case "LPF_Whole": { transformY = new Func <Double[], Double[], Double[]>((y, args) => y); transformWhole = new Func <double[][], double[], double[][]>((y, args) => Transformations.LPF(y, args[0], args[1])); addParameters(panelTransformParams, new string[] { "fcut", "m" }); break; } case "HPF_Whole": { transformY = new Func <Double[], Double[], Double[]>((y, args) => y); transformWhole = new Func <double[][], double[], double[][]>((y, args) => Transformations.HPF(y, args[0], args[1])); addParameters(panelTransformParams, new string[] { "fcut", "m" }); break; } case "Minus": { transformY = new Func <Double[], Double[], Double[]>((y, args) => y); transformWhole = new Func <double[][], double[], double[][]>((y, args) => Transformations.Minus(y, data[(int)args[0]])); addParameters(panelTransformParams, new string[] { "pictureNum" }); break; } case "Plus": { transformY = new Func <Double[], Double[], Double[]>((y, args) => y); transformWhole = new Func <double[][], double[], double[][]>((y, args) => Transformations.Plus(y, data[(int)args[0]])); addParameters(panelTransformParams, new string[] { "pictureNum" }); break; } case "MultiColorPlus": { transformY = new Func <Double[], Double[], Double[]>((y, args) => y); transformWhole = new Func <double[][], double[], double[][]>((y, args) => Transformations.MultiColorPlus(y, data[(int)args[0]])); addParameters(panelTransformParams, new string[] { "pictureNum" }); break; } case "Gradient": { transformY = new Func <Double[], Double[], Double[]>((y, args) => y); transformWhole = new Func <double[][], double[], double[][]>((y, args) => Transformations.Gradient(y)); addParameters(panelTransformParams, new string[] {}); break; } case "Laplassian": { transformY = new Func <Double[], Double[], Double[]>((y, args) => y); transformWhole = new Func <double[][], double[], double[][]>((y, args) => Transformations.Laplassian(y)); addParameters(panelTransformParams, new string[] { }); break; } case "Erosion": { transformY = new Func <Double[], Double[], Double[]>((y, args) => y); transformWhole = new Func <double[][], double[], double[][]>((y, args) => Transformations.ApplyMaskErosion(y, (int)args[0], args[1])); addParameters(panelTransformParams, new string[] { "mask width", "threshold" }); break; } case "Dilation": { transformY = new Func <Double[], Double[], Double[]>((y, args) => y); transformWhole = new Func <double[][], double[], double[][]>((y, args) => Transformations.ApplyMaskDilatation(y, (int)args[0], args[1])); addParameters(panelTransformParams, new string[] { "mask width", "threshold" }); break; } case "AddRandNoize": { transformY = new Func <Double[], Double[], Double[]>((y, args) => y); transformWhole = new Func <double[][], double[], double[][]>((y, args) => Transformations.ApplyRandNoize(y, args[0])); addParameters(panelTransformParams, new string[] { "power" }); break; } case "AddImpulseNoize": { transformY = new Func <Double[], Double[], Double[]>((y, args) => y); transformWhole = new Func <double[][], double[], double[][]>((y, args) => Transformations.ApplyNoizeSaltAndPepper(y, args[0])); addParameters(panelTransformParams, new string[] { "power" }); break; } case "AvgFilter": { transformY = new Func <Double[], Double[], Double[]>((y, args) => y); transformWhole = new Func <double[][], double[], double[][]>((y, args) => Transformations.AvgFilter(y, (int)args[0])); addParameters(panelTransformParams, new string[] { "mask width" }); break; } case "MedianFilter": { transformY = new Func <Double[], Double[], Double[]>((y, args) => y); transformWhole = new Func <double[][], double[], double[][]>((y, args) => Transformations.MedianFilter(y, (int)args[0])); addParameters(panelTransformParams, new string[] { "mask width" }); break; } case "Flood": { transformY = new Func <Double[], Double[], Double[]>((y, args) => y); //transformWhole = new Func<double[][], double[], double[][]>((y, args) => Transformations.Flood(y, (int)args[0])); addParameters(panelTransformParams, new string[] { "iterations" }); break; } case "FindAreas": { transformY = new Func <Double[], Double[], Double[]>((y, args) => y); transformWhole = new Func <double[][], double[], double[][]>((y, args) => { Colored = true; return(Transformations.MultiColorPlus(Transformations.FindAreas(y, (int)args[0]), y)); }); addParameters(panelTransformParams, new string[] { "stone size" }); break; } case "FindAreasWithPreproccessing": { transformY = new Func <Double[], Double[], Double[]>((y, args) => y); transformWhole = new Func <double[][], double[], double[][]>((y, args) => { var grad_stone = Transformations.Gradient(RescaleImage(Transformations.Negative(RescaleImage(y), 255))); var interstone = Transformations.Laplassian(RescaleImage(Transformations.Negative(RescaleImage(y), 255))); interstone = Transformations.Plus(interstone, interstone); interstone = Transformations.Plus(interstone, interstone); var a = Transformations.Minus(Transformations.Plus(RescaleImage(y), grad_stone), interstone); var b = Transformations.Plus(Transformations.ThresholdFun(a, 115, 115), Transformations.Laplassian(RescaleImage(y))); var c = Transformations.ThresholdFun(b, 115, 115); Colored = true; return(Transformations.MultiColorPlus(Transformations.FindAreas(c, (int)args[0]), y)); }); addParameters(panelTransformParams, new string[] { "stone size" }); break; } /* case "ConvolutionWithPlot": * { * * transformX = new Func<Double[], Double[], Double[]>((y, args) => { * * * Series series = chart.Series.FindByName(args[0].ToString()); * int m = series.Points.Select(item => item.YValues[0]).ToArray().Length; * * * return y.ToArray(); * }); * transformY = new Func<Double[], Double[], Double[]>((y, args) => { * Series series = chart.Series.FindByName(args[0].ToString()); * double[] h = series.Points.Select(item => item.YValues[0]).ToArray(); * double[] res = Transformations.ConvolutionWithPlot(h, y); * * return Transformations.Normalize(res); * }); * addParameters(panelTransformParams, new string[] { "Plot number" }); * break; * }*/ default: { break; } } }