Last active
August 8, 2023 05:17
-
-
Save ochilab/d720c9d961ed04b8c707 to your computer and use it in GitHub Desktop.
OpenCVSharpにてMatを利用してピクセルのRGB値を変更する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Mat m = new Mat(@"C:\Users\Public\Pictures\Sample Pictures\tu.jpg"); | |
Cv2.ImShow("before", m); | |
Mat m2 = new Mat(m.Height, m.Width, MatType.CV_8UC3); | |
for (int i = 0; i < m2.Height; i++){ | |
for (int j = 0; j < m2.Width; j++){ | |
byte by = 255; | |
Vec3b pix = m2.At<Vec3b>(i, j); | |
pix[0]=0; //B | |
pix[1] = by; //G | |
pix[2]=0; //R | |
m2.Set<Vec3b>(i, j, pix); | |
} | |
} | |
Cv2.ImShow("after", m2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment