1

I would like to detect all the angles in a given binary image , the image contains a handwriting character (black on white bg), is there a way that i can get the angles at the lines junctions with 100% accuracy?

My current solution (below) do find the angles but sometimes it finds unwanted angles - that is angles near the junction and not exectly on it (ther's an example below). In this implementation i use Magick.net,

because i cant post more than two links ill post the input letter image that suppose to be a binary image with blue marks that are the lcations of the angles i want to detect - to get the input binary image they will need to be deleted (sorry). letter A

My code:

    var image = new MagickImage(@"xImg.jpg");
    const int Radius = 3;//angle points surrounding circle radius
    image.Grayscale(PixelIntensityMethod.Average); //redundent
    var lineJunctionsImage = image.Clone(); // an image that will contain only the lines junctions points - angle points

    //detect all lines junctions points (black pixels points) in the image
    //with morphology method HAM + lineJunction kernel
    lineJunctionsImage.Negate();
    lineJunctionsImage.Morphology(MorphologyMethod.HitAndMiss, Kernel.LineJunctions);
    lineJunctionsImage.Negate();

resulting image

The resulting points are supposed to be the points on the middle of the junctions, but some are not accurate and its critical for me as i want to draw a circle that surrounds each of them and then take the angle between the point and the two points that intercects the circle, now, the next code is doing it but its to complicated and long so ill just write the algorithm here:

for each junction point p do: detect all black pixels bi(0 >= i) that intersects a circle with the above radius (3) that surrounds p, for each bi pairs calculate the angle between p and the pair print the angles found with the following protocol: {point1} {angle point} {point 2} angle

The angles found (the angle points (middle junctions points) marked):

{11,19} {8,17} {5,19} 112.619

{11,19} {8,17} {9,14} 105.255

{5,19} {8,17} {9,14} 142.12

{24,17} {21,20} {18,19} 116.56

{24,17} {21,20} {20,23} 90

{21,1} {24,0} {27,2} 127.87

{24,0} {27,2} {27,5} 123.7

{26,12} {27,9} {27,6} 161.56

I think the main problem is that the angle points are sometimes not the correct points but a close neighbor.

Maybe someone have a better more accurate idea that will find the correct angles.

Dr.Haimovitz
  • 1,568
  • 12
  • 16

0 Answers0