RGB值分割 [英] segmentation with RGB value

查看:104
本文介绍了RGB值分割的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为分割图像编写代码
我的目标是将我的图像(皮肤癌病变)与正常皮肤和病变皮肤进行细分
这是我的算法:
1.获取种子像素的值像素(0,0)
2.将值种子像素与一个相邻像素进行比较
3.如果No.3的值小于阈值(T),则转到下一个像素并转到No.2
4.如果No.3的值大于阈值(T),则将像素更改为白色(也用于下一个10像素),并获得新的种子值像素.
(我的图像之前有灰度)


i make a code for segmentation image
my goal is my image(leion of skin cancer) segmented with normal skin and lesion skin
this my algorithm :
1. get value pixel (0,0) for seed pixel
2. compare value seed pixel with one neighbor pixel
3. if value of no.3 less than treshold (T), go to next pixel and go to no.2
4. if value of no.3 more than treshold (T), change pixel to white(also for next 10 pixel), and get new seed value pixel.
(my image have greyscale before)


private void button4_Click(object sender, EventArgs e)
        {
            // GDI+ still lies to us - the return format is BGR, NOT RGB.
            BitmapData bmData = RImage.LockBits(new Rectangle(0, 0, RImage.Width, RImage.Height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);

            int stride = bmData.Stride;
            System.IntPtr Scan0 = bmData.Scan0;

            unsafe
            {
                byte* p = (byte*)(void*)Scan0;

                int nOffset = stride - RImage.Width * 3;

                for (int y = 0; y < RImage.Height; ++y)
                {                   
                    for (int x = 0; x < RImage.Width; ++x)
                    {  
                        if (x == 0)
                        {                            
                            //RImage.GetPixel(x, y);
                            seedR = p[x];
                            seedG = p[x+1];
                            seedB = p[x+2];
                        }
                        
                        if ((seedR - p[x] >= tred) || (p[x] - seedR >= tred))
                        {
                            //taruh value p dlu disini
                            for (int i=1; i <= 5; ++i)
                            {
                                p[x] = p[x + 1] = p[x + 2] = 0;
                                x++;
                            }

                            //RImage.GetPixel(x, y);
                            seedR = p[x];
                            seedG = p[x + 1];
                            seedB = p[x + 2];
                        }
                        p += 3;
                    }
                    p += nOffset;
                }
            }

            RImage.UnlockBits(bmData);
        }



我的问题是我的图像在图像的1/3中变白了
这有什么问题?



my problem is my image become white in 1/3 of image
what wrong this??

推荐答案

我强烈建议考虑将HSV/HSL颜色空间用于计算机视觉.

有关色彩空间的更一般的文章:
http://www.codeproject.com/KB/recipes/colorspace1.aspx [ ^ ]

一个很好的例子,如何做到这一点:
http://www.codeproject.com/KB/GDI-plus/HSLColorSpace.aspx [ ^ ]

祝你好运!
I would strongly advice to consider the HSV/HSL color space for computer vision.

A more general article on color spaces:
http://www.codeproject.com/KB/recipes/colorspace1.aspx[^]

A good example how to do this:
http://www.codeproject.com/KB/GDI-plus/HSLColorSpace.aspx[^]

Good luck!


这篇关于RGB值分割的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆