Click here to Skip to main content
16,020,628 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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);
        }


my problem is my image become white in 1/3 of image
what wrong this??
Posted
Updated 1-Dec-10 1:32am
v2
Comments
E.F. Nijboer 1-Dec-10 9:44am    
About your comment: "GDI+ still lies to us - the return format is BGR, NOT RGB"
Your processor is little endian and therefor stores an 32 RGBA value as ABGR in memory.
http://en.wikipedia.org/wiki/Endianness

1 solution

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!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900