c# – 删除非红色调色像素

c# – 删除非红色调色像素,第1张

概述我有一个非常简单的图像处理应用程序. I am trying to remove the pixels which do not involve red tones. 到目前为止,一个基本的代码似乎实现了我想要的. private void removeUnRedCellsBtn_Click(object sender, EventArgs e) { byt 我有一个非常简单的图像处理应用程序.

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的结果是

任何算法或想法都将非常感激.

提前致谢

解决方法 如果将RGB值转换为不同的颜色空间,如HSL或HSV,则可能会有更多的运气.查看维基百科上的 this link.将像素转换为其中一个颜色空间可帮助您隔离色相,这是您最关心的. 总结

以上是内存溢出为你收集整理的c# – 删除非红色调色像素全部内容,希望文章能够帮你解决c# – 删除非红色调色像素所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/1258230.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-07
下一篇 2022-06-07

发表评论

登录后才能评论

评论列表(0条)

保存