加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-15 06:27:29 所属栏目:百科 来源:网络整理
导读:我有一个非常简单的图像处理应用程序. I am trying to remove the pixels which do not involve red tones. 到目前为止,一个基本的代码似乎实现了我想要的. private void removeUnRedCellsBtn_Click(object sender,EventArgs e) { byte threshold = Convert.
我有一个非常简单的图像处理应用程序.

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.将像素转换为其中一个颜色空间可帮助您隔离色相,这是您最关心的.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读