Skip to content

Instantly share code, notes, and snippets.

@ochilab
Created May 30, 2013 10:08
Show Gist options
  • Save ochilab/5676919 to your computer and use it in GitHub Desktop.
Save ochilab/5676919 to your computer and use it in GitHub Desktop.
OpenCVSharpでの2値化処理
private IplImage binarize(IplImage src, int threshould) {
//グレースケールに変換
IplImage gray = new IplImage(src.Width,src.Height, BitDepth.U8, 1);
src.CvtColor(gray, ColorConversion.BgrToGray);
//二値化処理
Cv.Threshold(gray, gray, threshould, 255, ThresholdType.Binary);
return gray;
}
@ochilab
Copy link
Author

ochilab commented Jun 24, 2013

最初にグレースケール変換する際のgrayのサイズはsrcと同じにしておくこと。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment