Click here to Skip to main content
15,882,063 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
Please friend..help me to find out the best solution to convert my scanned image to text.
as the below code I tried but the result is not proper.


C#
protected void Page_Load(object sender, EventArgs e)
  {
      Image newImage = Image.FromFile(@"WebSite2/testingimagetotext.jpg");
      ImageToBase64(newImage, System.Drawing.Imaging.ImageFormat.Jpeg);
  }

  public string ImageToBase64(Image image, System.Drawing.Imaging.ImageFormat format)
  {
      using (MemoryStream ms = new MemoryStream())
      {
          // Convert Image to byte[]
          image.Save(ms, format);
          byte[] imageBytes = ms.ToArray();

          // Convert byte[] to Base64 String
          string base64String = Convert.ToBase64String(imageBytes);
          return base64String;
      }
  }
Posted
Comments
V.Lorz 18-Sep-13 8:32am    
What do you mean with 'convert image to text'? Convert the bytes that represent the image into some simple text representation? Do OCR on the image to extract some text present on it?

The sentence "ImageToBase64(newImage, System.Drawing.Imaging.ImageFormat.Jpeg);" in your code has no side effects if you do nothing with the string it returns.

You have still not understood that a "byte array" does not mean "text". Anything can be represented by a byte array. But "converting" x to a byte array and then converting the array to y does generally not result in anything useful.
When you want to recognize text on an image, you need a procedure called "Optical Character Recognition" (OCR). There are libraries available for that purpose.
Take care to select one which is appropriate for your texts (English or Hindi or Tamil?)!
 
Share this answer
 
Comments
imtiwapang 22-Sep-13 7:42am    
Actually I am not yet expert in this but logically I agreed with the use of "Optical Character Recognition" which will be if possible bring the character into C# code
you can simple use like:

C#
img1.imageData = System.IO.File.ReadAllBytes(MapPath("~/Images/Webcam.jpg"));
 
Share this answer
 
Thanks for your valuable time ....I got the code to convert my image(.jpeg) to text .using OCR library.
 
Share this answer
 
Comments
Member 10186638 19-Sep-13 7:59am    
it's not text...its byte array so say like convert image to byte

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900