Hi,

I am trying to implement a project where I need to detect something. I have the digitized form of a human cell and I need to detect regions separately in the image. This part is over. The next part is where I have to detect overlapping regions. Another part is to detect the nucleus of these cells. Can someone help me with the code?

You have to show us what you got before we can help you

Yikes, this is not a very easy task. Getting the image is easy, identifying pieces of an image is not. Unless you have a very long time to dedicate, I would not attempt this from scratch. If you do, I would research "Visual Pattern Recognition" (or "Image Pattern Recognition", same thing) and "Edge Detection". Both are very difficult topics.

If you want a head start, there are some commercial products that might help you, such as "Mathwork's Image Processing Toolkit" (http://www.mathworks.com/products/image/demos.html?file=/products/demos/shipping/images/ipexcell.html)

For comparison, consider how complex Optical Character Recognition is. You have a fixed alphabet, numbers and punctuation, only two colors you have to worry about, and it is still not an exact science after 20 years of development.

i am attaching the code here for reference. this is what i have done so far and this works perfectly fine. I dont know how to proceed after this

Main Class :

AForge.Imaging.Filters.Grayscale gs = new AForge.Imaging.Filters.Grayscale(0.2125, 0.7154, 0.0721);
Bitmap b = (Bitmap)pictureBox1.Image.Clone();
b = gs.Apply(b);
BitmapData bd = b.LockBits(new Rectangle(0, 0, b.Width, b.Height), ImageLockMode.ReadWrite, PixelFormat.Format8bppIndexed);
int stride;
stride = bd.Stride;
System.IntPtr scan0 = bd.Scan0;
int label = 2;
int[,] I = new int[bd.Width,bd.Height];
exec ex1 = new exec();
b = ex1.execute(bd, scan0, I, label, stride,b);
b.UnlockBits(bd);
pictureBox2.Image = b;
b.Save(@"c:\users\pashok\b.jpeg");
pictureBox2.Visible = true;

Exec Class

int i, j;
floodclass fc = new floodclass();

unsafe public Bitmap execute(BitmapData bd, System.IntPtr scan0,int[,] I,int label,int stride,Bitmap b)
{

byte* p = (byte*)(void*)scan0;
for (i = 1; i < bd.Height; i++)
{
for (j = 1; j < bd.Width; j++)
{
if (p[i * bd.Width + j] >= 242)
p[i * bd.Width + j] = 255;

if (p[i * bd.Width + j] != 255)
I[j, i] = 1;
else
I[j, i] = 0;
}
}
for (i = 1; i < bd.Height; i++)
{
for (j = 1; j < bd.Width; j++)
{
if (I[j, i] == 1)
{
I = fc.flood(p, j, i, label, bd, I);
++label;
}
}

}
for (i = 1; i < bd.Height; i++)
{
for (j = 1; j < bd.Width; j++)
{
p[i * stride + j] = (byte)(I[j, i] * 20);
}

}
return b;
}

Flood Class

unsafe public int[,] flood(byte* p, int x, int y, int label, BitmapData bd, int[,] I)
{
Stack s = new Stack();
Point poi = new Point(x, y);
Point temp = new Point();
s.Push(poi);
while (s.Count != 0)
{
Point pp = (Point)s.Pop();
if (pp.X < bd.Width && pp.Y < bd.Height && I[pp.X, pp.Y] == 1)
{
I[pp.X, pp.Y] = label;
temp.X = pp.X - 1;
temp.Y = pp.Y;
s.Push(temp);

temp.X = pp.X + 1;
temp.Y = pp.Y;
s.Push(temp);

temp.X = pp.X;
temp.Y = pp.Y - 1;
s.Push(temp);

temp.X = pp.X;
temp.Y = pp.Y + 1;
s.Push(temp);

temp.X = pp.X - 1;
temp.Y = pp.Y - 1;
s.Push(temp);

temp.X = pp.X - 1;
temp.Y = pp.Y + 1;
s.Push(temp);

temp.X = pp.X + 1;
temp.Y = pp.Y - 1;
s.Push(temp);

temp.X = pp.X + 1;
temp.Y = pp.Y + 1;
s.Push(temp);

}
}
return I;
}

This works perfectly. But it doesnt detect overlapping regions. As in, overlapping regions are counted as a single region. How can I separate them

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.