1.Cv2.ImRead
private Mat mSrc; (共通エリアで)
mSrc = Cv2.ImRead(openFileDialog1.FileName);
mat(画像を定義する構造体)に読込
グレスケールで読みこみ
mSrc = Cv2.ImRead(@”c:\work\henka1.jpg”,ImreadModes.Grayscale);
OpenCvSharp.Extensions.BitmapConverter.ToBitmap(mSrc)
matをビットマップへ変換
pictureBox1.Image = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(mSrc);

2.Cv2.BitwiseNot
全ビット反転
var dst = new Mat()
Cv2.BitwiseNot(mSrc, dst);
pictureBox1.Image = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(dst);

3.Cv2.CvtColor(
.Cv2.CvtColor(mSrc, dst, ColorConversionCodes.BGR2GRAY);
グレースケール

・Cv2.CvtColor(mSrc, dst, ColorConversionCodes.BGR2GRAY); // 輝度平滑化
Cv2.EqualizeHist(dst, dst); // 輝度平滑化
輝度平滑化

・Cv2.Threshold(mSrc, dst, 80.0, 210.0, ThresholdTypes.Binary)
または
Cv2.CvtColor(mSrc, dst, ColorConversionCodes.BGR2GRAY); グレー化
Cv2.Threshold(dst, dst, 80.0, 210.0, ThresholdTypes.Binary)
閾値 スレッショルド処理
または
Cv2.Threshold(mSrc, dst,128, 255, ThresholdTypes.BinaryInv)


