![プログラマ](https://rkhmy2000.com/wp-content/themes/cocoon/images/b-woman.png)
プログラマ
マネージャさん。画像を2値化したいと思います。教えていただけませんか?
![マネージャ](https://rkhmy2000.com/wp-content/uploads/2021/08/2f0c145d5ea502b3f018ccada393469a.jpg)
マネージャ
はい。この記事では画像を2値化する方法についてお話したいと思います。
画像を読み込んで2値化処理をして表示しましょう。
Mat th =new Mat();
Mat GRAY = new Mat();
Mat Img = new Mat (Path); //ここでPathは画像データがあるパス(ファイル名)
GRAY = Imp.CvtColor(ColorConversionCode.BGR2GRAY);
Cv2.Threshold(GRAY, Th, 128(閾値), 255(最大階調), ThresholdTypes.Binary);
pictureBox1.Image = BitmapConverter.ToBitmap(Th);