0

In that image particular height weight text need to be extract text. For that i used modiDocument. codes re below:

public string ExtractTextFromImage(string filepath)
{
    try
    {
        Document modiDocument = new Document();
        modiDocument.Create(filepath);
        modiDocument.OCR(MiLANGUAGES.miLANG_ENGLISH);
        MODI.Image modiImage = (modiDocument.Images[0] as MODI.Image);
        string extractedText = modiImage.Layout.Text;
        modiDocument.Close();
        return extractedText;
    }
    catch (Exception)
    {
        throw;
    }
    return filepath;
}

From above code i can get fill text from image. how to take particular height width text from image.

Muhammed Shevil KP
  • 1,404
  • 1
  • 16
  • 21
Malathi Mals
  • 73
  • 13

1 Answers1

0

Quote from https://stackoverflow.com/a/734941/3966756

You can use Graphics.DrawImage to draw a cropped image onto the graphics object from a bitmap.

Rectangle cropRect = new Rectangle(...);
Bitmap src = Image.FromFile(fileName) as Bitmap;
Bitmap target = new Bitmap(cropRect.Width, cropRect.Height);

using(Graphics g = Graphics.FromImage(target))
{
   g.DrawImage(src, new Rectangle(0, 0, target.Width, target.Height), 
                    cropRect,                        
                    GraphicsUnit.Pixel);
}

Quote end

Using this Code for cropping the image you can only load the part of the Image you want to extract the text from.

Since i don't know if MODIDocuments support loading from a bitmap instead of a file you may need to write a temporary file somwhereon your filesystem.

Community
  • 1
  • 1
Sebastian L
  • 838
  • 9
  • 29