gpt4 book ai didi

c# - 去除非红色调像素

转载 作者:可可西里 更新时间:2023-11-01 09:11:19 27 4
gpt4 key购买 nike

我有一个非常简单的图像处理应用程序。

I am trying to remove the pixels which do not involve red tones.

到目前为止,基本代码似乎可以实现我想要的。

        private void removeUnRedCellsBtn_Click(object sender, EventArgs e)
{
byte threshold = Convert.ToByte(diffTxtBox.Text);
byte r, g, b;
for (int i = 0; i < m_Bitmap.Width; i++)
{
for (int j = 0; j < m_Bitmap.Height; j++)
{
r = im_matrix[i, j].R;
g = im_matrix[i, j].G;
b = im_matrix[i, j].B;
if ((r - b) < threshold || (r - g) < threshold)
{
m_Bitmap.SetPixel(i, j, Color.White);
}

}
}
pictureArea_PictureBox.Image = m_Bitmap;
}

基本上,如果(红色和蓝色)或(红色和绿色)的差异小于阈值,它会将像素设置为白色。

My results seems to be promising however I am wondering if there is a better solution for determining whether a pixel involves red tones in it.

我的阈值为 75 的结果是 before after

任何算法或想法将不胜感激。

提前致谢

matlab imtool

最佳答案

如果将 RGB 值转换为不同的颜色空间,例如 HSL 或 HSV,您可能会更幸运。查看this link在维基百科上。将像素转换为这些颜色空间之一应该可以帮助您隔离色调,这是您最关心的。

关于c# - 去除非红色调像素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5514260/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com