Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I made a project to detect the edge of skin cancer lesions.
My goal is to make the dividing line between cancerous lesions and healthy skin.
Input: pictures of skin cancer lesions.
output: images of lesions with the dividing line.
I use the following algorithm
1. check the value of a pixel (already greyscale)
2. if it meets the boundary, mark by giving a value of 1.
3. if not, the mark by giving the value 0.
4. check back for a pixel, 8 neighbors check
5. if all neighbors together, meaning he is not the edge.
6. if the eight neighboring pixels are different means edge, change the pixel value to 255.
My problem, I created this code can not separate the lesion and healthy skin.
maybe there is something wrong with my code or algorithms.
thank you

private void button4_Click(object sender, EventArgs e)
        {
            minq = 120;
            maxq = 240;
            // 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 (p[x] <= maxq && p[x] >= minq)
                        {
                            arraynilai[x, y] = 1;
                        }
                        else
                        {
                            arraynilai[x, y] = 0;
                        }                       

                        p += 3;
                    }
                    p += nOffset;
                }
            }

            RImage.UnlockBits(bmData);
        }

        private void button6_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 = 1; y < RImage.Height; ++y)
                {
                    for (int x = 1; x < RImage.Width; ++x)
                    {
                        rc1 = arraynilai[x - 1, y - 1];
                        rc2 = arraynilai[x , y - 1];
                        rc3 = arraynilai[x + 1, y - 1];
                        rc4 = arraynilai[x + 1, y];
                        rc5 = arraynilai[x + 1, y + 1];
                        rc6 = arraynilai[x , y + 1];
                        rc7 = arraynilai[x - 1, y + 1];
                        rc8 = arraynilai[x - 1, y];

                        if (rc1 + rc2 + rc3 + rc4 + rc5 + rc6 + rc7 + rc8 < 8)
                        {
                            p[0] = p[1] = p[2] = 255; 
                        }

                        p += 3;
                    }
                    p += nOffset;
                }
            }

            RImage.UnlockBits(bmData); 
        }
Posted
Comments
JF2015 26-Dec-10 5:06am    
Don't repost your question. You could have modified the existing question by using the "Improve question" feature.

1 solution

You need to think about it.
We can't really help you, even given the code you have, for a couple of reasons:

1) I don't have any pictures of skin cancer - or at least I wouldn't recognise3s such a picture. So we cannot test it.
2) We don't know what criteria mark "the edge of skin cancer lesions" so even with pictures we couldn't be sure what we are looking at.

What I suggest is:
1) Take a simple sample of a lesion. Simplify it in a paint package until it is black and white.
2) Run your code. Detect the edges.
3) Use a less simplified version of the same picture.
4) Repeat until your code works for an unaltered picture.
5) Try again with a second picture, and a third, and so forth.

Sorry, but there are limits to how much help we can give.
 
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