Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: How to read a text from an Image file?

  1. #1
    Junior Member
    Join Date
    Aug 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How to read a text from an Image file?

    I need to read a Text(Account Number) from a image file (.tif).
    I tried the following approach :

     try{   								
                    File newFile=new File("C:\\Image\\9R6-CCI\\09082010\\K08E091209FT_8021.tif");
    	BufferedImage buffImage=ImageIO.read(newFile);
    	ByteArrayOutputStream os= new ByteArrayOutputStream();		
    	ImageIO.write(buffImage,IMAGE_TYPE,os);
    	byte []data=os.toByteArray();
    	String imageString=new BASE64Encoder().encode(data);
    	}catch (Exception e){}

    But it was throwing problem. After googling, I found that ImageIO has some limitation to read an editable image.
    Then, I tried the following approach :

     try{File newFile=new File("C:\\Image\\9R6-CCI\\09082010\\K08E091209FT_8033.tif");
    		   byte[] fileData = new byte[ (int)newFile.length()];
    	   InputStream inStream = new FileInputStream( newFile);	
    	  inStream.read(fileData);		
    	  inStream.close();
    	  String tempFileData = new String(fileData);		
    	  String imageString=new BASE64Encoder().encode(fileData);				}catch (Exception e){}
    But i did n't get the desired out put . The Out put is as below.
    xTFMUxTFMUxTFMUxTFMUxTFMUxTFMUxTFMUxTFMUxTFMUxTFMU xTFMUxTFMUxTFMUxTFMUxTFMUx

    Please, help me to address the issue.

    Thanks and Regards
    Gautam
    Last edited by helloworld922; August 11th, 2010 at 09:22 AM.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: How to read a text from an Image file?

    I don't see how you can "read" text from an image file. Can you explain? How was the image file created?
    Are you talking about scanning an image for "letters" as in character recognition.

  3. #3
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,895
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: How to read a text from an Image file?

    The text of an image isn't stored in an easily accessible way for the computer to recognize. You'll need a text recognition algorithm to help you decipher what the text is. Do note that if the text is hand-written, or was generated to be illegible (but still readable by a human reader), you will get inaccurate results as this is still an open area of research in computer science.

  4. #4
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: How to read a text from an Image file?

    The Java Advanced Imaging package should be able to read tiff files. I'm not sure there is a method that allows you to read out any header data if this is what you need. You may want to look into this package and see, try and find another package which will help, or consider writing your own tiff parser (you need to closely inspect the file format for this option, just reading in the file might not cut it)

  5. #5
    Junior Member
    Join Date
    Oct 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How to read a text from an Image file?

    Hi Gautam,

    Please let me know for any solution you found on this at yeddu.lakshmana@gmail.com.

    Thanks,
    Lakshman

Similar Threads

  1. java program to copy a text file to onother text file
    By francoc in forum File I/O & Other I/O Streams
    Replies: 3
    Last Post: April 23rd, 2010, 03:10 PM
  2. Text capturing from image
    By kishore in forum Java SE APIs
    Replies: 0
    Last Post: March 5th, 2010, 09:47 AM
  3. Read data from text file
    By yroll in forum Algorithms & Recursion
    Replies: 4
    Last Post: December 31st, 2009, 01:40 AM
  4. Text to Tiff Image
    By sreddy_k in forum File I/O & Other I/O Streams
    Replies: 4
    Last Post: August 13th, 2009, 12:36 AM
  5. How to read character from image area(jpg image)?
    By sundarjothi in forum Java Theory & Questions
    Replies: 5
    Last Post: August 6th, 2008, 02:08 AM