Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Separate letters in image c#

I have images with 6 letters and I wish to separte it into 6 images with 1 letter each. I was using this function:

public static List<UnmanagedImage> ApplyBlobExtractor (UnmanagedImage unmanaged)
        {
            // Extract blobs
            BlobCounter blobCounter  = new BlobCounter ();
            blobCounter.ObjectsOrder = ObjectsOrder.XY;
            blobCounter.ProcessImage (unmanaged);

            // Add blobs into list
            Blob[] blobs = blobCounter.GetObjects (unmanaged, false);
            List<UnmanagedImage> unmanagedList = new List<UnmanagedImage> (blobs.Length);
            foreach (Blob blob in blobs)
                unmanagedList.Add (blob.Image);

            return unmanagedList;
        }

The problem is that sometimes the letters are touching each other and this make the function recognize the 2 letters as a single one. Is there a way to improve my function or create a better one?

This is an example of image that is giving wrong result: enter image description here

The function is giving me 2 images instead of 6.

Image 1 :enter image description here

Image 2:enter image description here

like image 618
Carlos Siestrup Avatar asked Nov 09 '22 06:11

Carlos Siestrup


1 Answers

You can try to use clustering methods as a start.

A quick test with python's scikit spectral clustering gives me this result:

enter image description here

I don't know what exists in C# though.

like image 153
Gwen Avatar answered Nov 30 '22 13:11

Gwen