0
검은 색 이미지를 그레이 스케일 image.my로 변환해야합니다. 이미지를 그레이 스케일 이미지로 변환합니다 .을 그레이 스케일 이미지로 변환합니다. 또한 회색에서 회색으로 작동하지 않습니다. 이미지 변환. 링크는 https://stackoverflow.com/a/2265990/8569792검은 색 이미지로 회색조 이미지로 변환
public void GreyScaleConversion()
{
//read image
Bitmap bmp = global::Ribbon.Properties.Resources.Device;
//load original image in picturebox1
pictureBox1.Image = global::Ribbon.Properties.Resources.Device;
//get image dimension
int width = bmp.Width;
int height = bmp.Height;
//color of pixel
Color p;
//grayscale
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
//get pixel value
p = bmp.GetPixel(x, y);
//extract pixel component ARGB
int a = p.A;
int r = p.R;
int g = p.G;
int b = p.B;
//find average
int avg = (r + g + b)/3;
//set new pixel value
bmp.SetPixel(x, y, Color.FromArgb(a, avg, avg, avg));
}
}
//load grayscale image in picturebox2
pictureBox2.Image = bmp;
}