private void btnOK_Click( object sender, EventArgs e ) { if( !cbIsUseSizeThreshold.Checked ) { ThresholdType = ThresholdType.None; } else { ThresholdType = comboThresholdType.Text == "Least" ? ThresholdType.Least : comboThresholdType.Text == "Most" ? ThresholdType.Most : ThresholdType.None; Bound = (long)nudThreshold.Value * 1024; } IsUpdateExistChecksum = cbIsRecomputeAll.Checked; IsOK = true; Close(); }
/// <summary> /// Applies an adaptive threshold to an array. /// Source matrix must be 8-bit single-channel image. /// </summary> /// <param name="maxValue">Non-zero value assigned to the pixels for which the condition is satisfied. See the details below.</param> /// <param name="adaptiveMethod">Adaptive thresholding algorithm to use, ADAPTIVE_THRESH_MEAN_C or ADAPTIVE_THRESH_GAUSSIAN_C .</param> /// <param name="thresholdType">Thresholding type that must be either THRESH_BINARY or THRESH_BINARY_INV .</param> /// <param name="blockSize">Size of a pixel neighborhood that is used to calculate a threshold value for the pixel: 3, 5, 7, and so on.</param> /// <param name="c">Constant subtracted from the mean or weighted mean (see the details below). /// Normally, it is positive but may be zero or negative as well.</param> /// <returns>Destination image of the same size and the same type as src.</returns> public Mat AdaptiveThreshold(double maxValue, AdaptiveThresholdType adaptiveMethod, ThresholdType thresholdType, int blockSize, double c) { var dst = new Mat(); Cv2.AdaptiveThreshold(this, dst, maxValue, adaptiveMethod, thresholdType, blockSize, c); return dst; }
/// <summary> /// Applies a fixed-level threshold to each array element. /// The input matrix must be single-channel, 8-bit or 32-bit floating point. /// </summary> /// <param name="thresh">threshold value.</param> /// <param name="maxval">maximum value to use with the THRESH_BINARY and THRESH_BINARY_INV thresholding types.</param> /// <param name="type">thresholding type (see the details below).</param> /// <returns>output array of the same size and type as src.</returns> public Mat Threshold(double thresh, double maxval, ThresholdType type) { var dst = new Mat(); Cv2.Threshold(this, dst, thresh, maxval, type); return dst; }
public static extern void cvAdaptiveThreshold(IntPtr src, IntPtr dst, double max_value, AdaptiveThresholdType adaptiveType, ThresholdType threshold_type, int block_size, double param1);
private static extern void cveNiBlackThreshold(IntPtr src, IntPtr dst, double maxValue, ThresholdType type, int blockSize, double delta);
/// <summary> /// Niblack threshold /// </summary> /// <param name="src">The source image</param> /// <param name="dst">The output result</param> /// <param name="type">Threshold type</param> /// <param name="blockSize">Block size</param> /// <param name="delta">delta</param> /// <param name="maxValue">Maximum value to use with CV_THRESH_BINARY and CV_THRESH_BINARY_INV thresholding types</param> public static void NiBlackThreshold(IInputArray src, IOutputArray dst, double maxValue, ThresholdType type, int blockSize, double delta) { using (InputArray iaSrc = src.GetInputArray()) using (OutputArray oaDst = dst.GetOutputArray()) { cveNiBlackThreshold(iaSrc, oaDst, maxValue, type, blockSize, delta); } }
/// <summary> /// Applies an adaptive threshold to an array. /// </summary> /// <param name="src">Source 8-bit single-channel image.</param> /// <param name="dst">Destination image of the same size and the same type as src .</param> /// <param name="maxValue">Non-zero value assigned to the pixels for which the condition is satisfied. See the details below.</param> /// <param name="adaptiveMethod">Adaptive thresholding algorithm to use, ADAPTIVE_THRESH_MEAN_C or ADAPTIVE_THRESH_GAUSSIAN_C .</param> /// <param name="thresholdType">Thresholding type that must be either THRESH_BINARY or THRESH_BINARY_INV .</param> /// <param name="blockSize">Size of a pixel neighborhood that is used to calculate a threshold value for the pixel: 3, 5, 7, and so on.</param> /// <param name="c">Constant subtracted from the mean or weighted mean (see the details below). /// Normally, it is positive but may be zero or negative as well.</param> public static void AdaptiveThreshold(InputArray src, OutputArray dst, double maxValue, AdaptiveThresholdType adaptiveMethod, ThresholdType thresholdType, int blockSize, double c) { if (src == null) throw new ArgumentNullException("src"); if (dst == null) throw new ArgumentNullException("dst"); src.ThrowIfDisposed(); dst.ThrowIfNotReady(); NativeMethods.imgproc_adaptiveThreshold(src.CvPtr, dst.CvPtr, maxValue, (int)adaptiveMethod, (int)thresholdType, blockSize, c); dst.Fix(); }
/// <summary> /// Applies a fixed-level threshold to each array element. /// </summary> /// <param name="src">input array (single-channel, 8-bit or 32-bit floating point).</param> /// <param name="dst">output array of the same size and type as src.</param> /// <param name="thresh">threshold value.</param> /// <param name="maxval">maximum value to use with the THRESH_BINARY and THRESH_BINARY_INV thresholding types.</param> /// <param name="type">thresholding type (see the details below).</param> /// <returns>the computed threshold value when type == OTSU</returns> public static double Threshold(InputArray src, OutputArray dst, double thresh, double maxval, ThresholdType type) { if (src == null) throw new ArgumentNullException("src"); if (dst == null) throw new ArgumentNullException("dst"); src.ThrowIfDisposed(); dst.ThrowIfNotReady(); double ret = NativeMethods.imgproc_threshold(src.CvPtr, dst.CvPtr, thresh, maxval, (int)type); dst.Fix(); return ret; }
private void btnCancel_Click( object sender, EventArgs e ) { ThresholdType = ThresholdType.None; IsOK = false; Close(); }
/// <summary> /// 適応的な閾値処理を行い、グレースケール画像を2値画像に変換する /// </summary> /// <param name="src">入力画像</param> /// <param name="dst">出力画像</param> /// <param name="maxValue">threshold_type がBinaryあるいはBinaryInvのときに用いる最大値</param> /// <param name="adaptiveMethod">適応的閾値処理で使用するアルゴリズム</param> /// <param name="thresholdType">閾値処理の種類. BinaryかBinaryInvのどちらか</param> /// <param name="blockSize">ピクセルの閾値を計算するために用いる隣接領域のサイズ: 3, 5, 7, ... </param> /// <param name="param1">各適応手法に応じたパラメータ. 適応手法がMeanCおよびGaussianCの場合は,平均値または重み付き平均値から引く定数. 負の値の場合もある.</param> #else /// <summary> /// Applies adaptive threshold to array. /// </summary> /// <param name="src">Source image.</param> /// <param name="dst">Destination image. </param> /// <param name="maxValue">Maximum value that is used with Binary and BinaryInv. </param> /// <param name="adaptiveMethod">Adaptive thresholding algorithm to use: MeanC or GaussianC.</param> /// <param name="thresholdType">Thresholding type.</param> /// <param name="blockSize">The size of a pixel neighborhood that is used to calculate a threshold value for the pixel: 3, 5, 7, ... </param> /// <param name="param1">The method-dependent parameter. For the methods MeanC and GaussianC it is a constant subtracted from mean or weighted mean (see the discussion), though it may be negative. </param> #endif public static void AdaptiveThreshold(CvArr src, CvArr dst, double maxValue, AdaptiveThresholdType adaptiveMethod, ThresholdType thresholdType, int blockSize, double param1) { if (src == null) throw new ArgumentNullException("src"); if (dst == null) throw new ArgumentNullException("dst"); if (thresholdType != ThresholdType.Binary && thresholdType != ThresholdType.BinaryInv) { throw new ArgumentException("thresholdType == Binary || thresholdType == BinaryInv"); } NativeMethods.cvAdaptiveThreshold(src.CvPtr, dst.CvPtr, maxValue, adaptiveMethod, thresholdType, blockSize, param1); }
/// <summary> /// 適応的な閾値処理を行い、グレースケール画像を2値画像に変換する /// </summary> /// <param name="src">入力画像</param> /// <param name="dst">出力画像</param> /// <param name="maxValue">threshold_type がBinaryあるいはBinaryInvのときに用いる最大値</param> /// <param name="adaptiveMethod">適応的閾値処理で使用するアルゴリズム</param> /// <param name="thresholdType">閾値処理の種類. BinaryかBinaryInvのどちらか</param> /// <param name="blockSize">ピクセルの閾値を計算するために用いる隣接領域のサイズ: 3, 5, 7, ... </param> #else /// <summary> /// Applies adaptive threshold to array. /// </summary> /// <param name="src">Source image.</param> /// <param name="dst">Destination image. </param> /// <param name="maxValue">Maximum value that is used with Binary and BinaryInv. </param> /// <param name="adaptiveMethod">Adaptive thresholding algorithm to use: MeanC or GaussianC.</param> /// <param name="thresholdType">Thresholding type.</param> /// <param name="blockSize">The size of a pixel neighborhood that is used to calculate a threshold value for the pixel: 3, 5, 7, ... </param> #endif public static void AdaptiveThreshold(CvArr src, CvArr dst, double maxValue, AdaptiveThresholdType adaptiveMethod, ThresholdType thresholdType, int blockSize) { AdaptiveThreshold(src, dst, maxValue, adaptiveMethod, thresholdType, blockSize, 5); }
/// <summary> /// 適応的な閾値処理を行い、グレースケール画像を2値画像に変換する /// </summary> /// <param name="src">入力画像</param> /// <param name="dst">出力画像</param> /// <param name="max_value">threshold_type がBinaryあるいはBinaryInvのときに用いる最大値</param> /// <param name="adaptive_method">適応的閾値処理で使用するアルゴリズム</param> /// <param name="threshold_type">閾値処理の種類. BinaryかBinaryInvのどちらか</param> /// <param name="block_size">ピクセルの閾値を計算するために用いる隣接領域のサイズ: 3, 5, 7, ... </param> /// <param name="param1">各適応手法に応じたパラメータ. 適応手法がMeanCおよびGaussianCの場合は,平均値または重み付き平均値から引く定数. 負の値の場合もある.</param> #else /// <summary> /// Applies adaptive threshold to array. /// </summary> /// <param name="src">Source image.</param> /// <param name="dst">Destination image. </param> /// <param name="max_value">Maximum value that is used with CV_THRESH_BINARY and CV_THRESH_BINARY_INV. </param> /// <param name="adaptive_method">Adaptive thresholding algorithm to use: CV_ADAPTIVE_THRESH_MEAN_C or CV_ADAPTIVE_THRESH_GAUSSIAN_C.</param> /// <param name="threshold_type">Thresholding type.</param> /// <param name="block_size">The size of a pixel neighborhood that is used to calculate a threshold value for the pixel: 3, 5, 7, ... </param> /// <param name="param1">The method-dependent parameter. For the methods CV_ADAPTIVE_THRESH_MEAN_C and CV_ADAPTIVE_THRESH_GAUSSIAN_C it is a constant subtracted from mean or weighted mean (see the discussion), though it may be negative. </param> #endif public static void AdaptiveThreshold(CvArr src, CvArr dst, double max_value, AdaptiveThresholdType adaptive_method, ThresholdType threshold_type, int block_size, double param1) { if (src == null) throw new ArgumentNullException("src"); if (dst == null) throw new ArgumentNullException("dst"); if (threshold_type != ThresholdType.Binary && threshold_type != ThresholdType.BinaryInv) { throw new ArgumentOutOfRangeException("閾値処理の種類は、BinaryかBinaryInvのどちらかである必要があります。"); } CvInvoke.cvAdaptiveThreshold(src.CvPtr, dst.CvPtr, max_value, adaptive_method, threshold_type, block_size, param1); }
/// <summary> /// 適応的な閾値処理を行い、グレースケール画像を2値画像に変換する /// </summary> /// <param name="src">入力画像</param> /// <param name="dst">出力画像</param> /// <param name="max_value">threshold_type がBinaryあるいはBinaryInvのときに用いる最大値</param> /// <param name="adaptive_method">適応的閾値処理で使用するアルゴリズム</param> /// <param name="threshold_type">閾値処理の種類. BinaryかBinaryInvのどちらか</param> /// <param name="block_size">ピクセルの閾値を計算するために用いる隣接領域のサイズ: 3, 5, 7, ... </param> #else /// <summary> /// Applies adaptive threshold to array. /// </summary> /// <param name="src">Source image.</param> /// <param name="dst">Destination image. </param> /// <param name="max_value">Maximum value that is used with CV_THRESH_BINARY and CV_THRESH_BINARY_INV. </param> /// <param name="adaptive_method">Adaptive thresholding algorithm to use: CV_ADAPTIVE_THRESH_MEAN_C or CV_ADAPTIVE_THRESH_GAUSSIAN_C.</param> /// <param name="threshold_type">Thresholding type.</param> /// <param name="block_size">The size of a pixel neighborhood that is used to calculate a threshold value for the pixel: 3, 5, 7, ... </param> #endif public static void AdaptiveThreshold(CvArr src, CvArr dst, double max_value, AdaptiveThresholdType adaptive_method, ThresholdType threshold_type, Int32 block_size) { AdaptiveThreshold(src, dst, max_value, adaptive_method, threshold_type, block_size, 5); }
public Threshold(int downLimit = 50, int upLimit = 60, ThresholdType type = ThresholdType.Binary) { this.downLimit = downLimit; this.upLimit = upLimit; this.type = type; }