private void OnBicubicCheck(object sender, EventArgs e) { if (rbBicubic.Checked) { methodIntp = InterpolateMethod.Bicubic; } }
private void OnrbBilinearCheck(object sender, EventArgs e) { if (rbBilinear.Checked) { methodIntp = InterpolateMethod.Bilinear; } }
private void OnrbNearestCheck(object sender, EventArgs e) { if (rbNearest.Checked) { methodIntp = InterpolateMethod.Nearest; } }
/// <summary> /// Execute Resampling. /// </summary> public void Execute() { Progress = 0; if (_param == null) { return; } if (_result != null) { _result.Dispose(); } _result = new ResamplingResult(); //Calculate resampling point. double[] xi = CreateResamplingPoint(); if (xi == null) { return; } for (int i = 0; i < _param.GetXYDataNum(); i++) { if (StopFlag) { return; } ClrDataPoints xyData = _param.GetXYData(i); double[] yi; double[,] data; yi = new double[xi.Length]; ConvertXYDataToXYArray(xyData, out data); InterpolateMethod method = _param.Interpolation == ResamplingParameter.InterpolationAlgorithm.LINEAR ? InterpolateMethod.LINEAR : InterpolateMethod.PCHIP; if (UpdateResamplingProgress != null) { UpdateResamplingProgress(PROGRESS_RESAMPLING_PHASE.RESAMPLING_START, 0, i + 1, _param.GetXYDataNum()); } WrapMatlabInterp1(yi, data.GetLength(1), data, xi.Length, xi, method, ExtrapolateType.FILL_ZERO); _result.AddData(xi, yi); if (UpdateResamplingProgress != null) { UpdateResamplingProgress(PROGRESS_RESAMPLING_PHASE.RESAMPLING_DOING, 0, i + 1, _param.GetXYDataNum()); } Progress++; } if (UpdateResamplingProgress != null) { UpdateResamplingProgress(PROGRESS_RESAMPLING_PHASE.RESAMPLING_END, 0, _param.GetXYDataNum(), _param.GetXYDataNum()); } }
/// <summary> /// interpolate between x1 and x2 to ty suing the interpolate method /// </summary> /// <param name="method"></param> /// <param name="x1"></param> /// <param name="x2"></param> /// <param name="t"></param> /// <returns></returns> public static float Interpolate(float x1, float x2, float t, InterpolateMethod method = InterpolateMethod.Linear) { if (method == InterpolateMethod.Linear) { return(Mathf.Lerp(x1, x2, t)); } else { return(Mathf.Pow(x1, 1 - t) * Mathf.Pow(x2, t)); } }
public int Step(Point2d ptSrc, InterpolateMethod methodIntp) { // The atomic operation to calculate the interpolated value. switch (methodIntp) { case InterpolateMethod.Bicubic: return(Bicubic(GetNeighbourhood16(ptSrc), ptSrc)); case InterpolateMethod.Bilinear: return(Bilinear(GetNeighbourhood4(ptSrc), ptSrc)); case InterpolateMethod.Nearest: return(GetNeighbourhood1(ptSrc)); default: throw new ArgumentException("Invalid methodIntp."); } }
private void InitData() { // Set the initial data. det.LoadModel("./model/DetectorModel.dat"); pbDst.Image = new Bitmap("./data/test.jpg"); idxImgSrc = 1; idxImgGuide = 1; srcImgChanged = true; guideImgChanged = true; srcMrkShown = false; guideMrkShown = false; mineSrc = false; mineGuide = false; rbNearest.Checked = true; rbBsp.Checked = true; methodIntp = InterpolateMethod.Nearest; methodDeform = DeformMethod.BSpline; algn1 = new Point2d[nAlign]; algn2 = new Point2d[nAlign]; }
static extern void WrapMatlabInterp1(double[] interYArray, int dataSize, double[,] dataArray, int interSize, double[] interXArray, InterpolateMethod Method, ExtrapolateType Extrap_value);