15,961,997 members
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
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

## Solution 1

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!