Home | Blog | Software | Reviews and Features | Forum | Help | Donate | About us
topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • September 04, 2015, 10:46:00 PM
  • Proudly celebrating 10 years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Tim - Image to Text Converter  (Read 40587 times)

TPReal

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 121
    • View Profile
    • Donate to Member
Tim - Image to Text Converter
« on: December 28, 2007, 01:58:56 PM »
Tim - Image to Text Converter

The program converts an image (jpg or bmp) to a text, which looks like the image in grayscale. You can choose any monospaced font and any font size you want to format the text with, and also any set of allowed characters. The result can be saved as text and then you can format it correctly in a text editor, or you can save the image of the text already correctly formatted.

The program was written in C++Builder 2006 and might need some dll's and bpl's to run. They might be available for download here: http://etonne.110mb.com/files/libs.zip
Put them in the program directory, or in your system directory.

[attachthumb=#1][/attachthumb]
[attachthumb=#2][/attachthumb]

Download the program:
[attachurl=#3][/attachurl]

tomos

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 9,524
    • View Profile
    • Donate to Member
Re: Tim - Image to Text Converter
« Reply #1 on: December 28, 2007, 02:04:47 PM »
wow, looks really beautiful that text  :up:
Tom

CodeTRUCKER

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,032
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: Tim - Image to Text Converter
« Reply #2 on: January 01, 2008, 01:00:44 AM »
Nice!  Would you mind explaining the algorithm used to determine the density of the characters?  That is if it is not proprietary. :-[
« Last Edit: January 22, 2008, 06:55:12 PM by CodeTRUCKER »

TPReal

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 121
    • View Profile
    • Donate to Member
Re: Tim - Image to Text Converter
« Reply #3 on: January 02, 2008, 03:45:42 AM »
I'm glad you like it :)

Character density algorithm
Calculating the density of characters was rather easy in Borland's IDE. Let im be an image, then:
Code: C++
  1. im->Canvas->Font=font_you_use_for_conversion;
  2. int width=im->Canvas->TextWidth('x'),height=im->Canvas->TextHeight('x');
  3.  
Now we have the size of a character. The font is monospaced so I can use 'x' or any other character. Now for ch being each character in turn, I clear the image, then print the character on it:
Code: C++
  1. im->Canvas->TextOutA(10,10,ch);
  2. int counter=0;
  3.  
Then in loop where i changes from, say, 0 to width+10 and j from 0 to height+10:
Code: C++
  1. counter+=im->Canvas->Pixels[i][j]&0x0000FF;
  2.  
Finally, the density of ink for this character is:
Code: C++
  1. 1-(double)counter/255/width/height
  2.  
Note that the area that you check inside the (i;j) loop must be greater than the character width*height rectangle because a lot of characters exceed this size. The size is used only to determine the horizontal and vertical distance between characters.

Note also that just counting black pixels in the loop is not a good idea, because some fonts, especially small sized (like 2 or 3) include also some gray pixels which also have to be counted in.

Finally I cut the input image into width*height rectangles and for each of them I calculate the density of ink in a similar way as I did it for characters (only now I have to take into account all colors, and also the color weights) and for each rectangle I use the character that fits best.

This is not the actual code of the program, but I think it is more or less correct and shows the main idea :)


CodeTRUCKER

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,032
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: Tim - Image to Text Converter
« Reply #4 on: January 02, 2008, 03:51:41 AM »
Thank you for the explanation.  I learned something! :Thmbsup:
« Last Edit: January 22, 2008, 06:56:15 PM by CodeTRUCKER »

varunkumar

  • Participant
  • Joined in 2007
  • *
  • Posts: 2
    • View Profile
    • Donate to Member
Re: Tim - Image to Text Converter
« Reply #5 on: January 14, 2008, 07:48:07 AM »
Good utility, also free.  :D

PantherDave

  • Participant
  • Joined in 2007
  • *
  • default avatar
  • Posts: 1
    • View Profile
    • Donate to Member
Re: Tim - Image to Text Converter
« Reply #6 on: January 14, 2008, 10:17:26 PM »
Well it looks cool, but I can't get it to work.  I've tried many photos and settings but I always get what looks like random text.  Do you know what I might be doing wrong?

TPReal

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 121
    • View Profile
    • Donate to Member
Re: Tim - Image to Text Converter
« Reply #7 on: January 15, 2008, 10:56:57 AM »
Hmm, try to change color mapping so that the line is more steep, it improves contrast. Look at the histograms to decide where the line should lie. You could also play with the color sliders but even I do not understand fully how they affect the resulting image :)
If you still think something does not work like it should, you can send me this image, or post it here, and I'll try to do something with it.
TPR.

somps

  • Participant
  • Joined in 2006
  • *
  • default avatar
  • Posts: 17
    • View Profile
    • Donate to Member
Re: Tim - Image to Text Converter
« Reply #8 on: April 10, 2008, 08:49:37 AM »
I try to run it in Vista and I get an error that says it can't find vcl100.bpl.
 :P

TPReal

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 121
    • View Profile
    • Donate to Member
Re: Tim - Image to Text Converter
« Reply #9 on: April 10, 2008, 12:02:59 PM »
Hello. Did you download the libraries I give link to in the first post? Put them in the program's directory or in windows\system or however it is called on vista.

jeremejazz

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 58
  • hey!
    • View Profile
    • Jereme's Pinboard
    • Donate to Member
Re: Tim - Image to Text Converter
« Reply #10 on: April 02, 2009, 05:47:49 AM »
It's nice.. haha... I like this program.. So it's written in C Language? did u make this?...
:) I love coding

anniearsenal

  • Participant
  • Joined in 2009
  • *
  • Posts: 2
    • View Profile
    • Donate to Member
Re: Tim - Image to Text Converter
« Reply #11 on: July 03, 2009, 12:00:15 AM »
it isnt working :|

jeremejazz

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 58
  • hey!
    • View Profile
    • Jereme's Pinboard
    • Donate to Member
Re: Tim - Image to Text Converter
« Reply #12 on: October 26, 2009, 04:42:15 AM »
 ;Doh .. it seems that you just made some error aniearsenal..
Is the program not running?.. you need to extract the library files to where youput the application
:) I love coding

assk7

  • Participant
  • Joined in 2006
  • *
  • default avatar
  • Posts: 9
    • View Profile
    • Donate to Member
Re: Tim - Image to Text Converter
« Reply #13 on: July 22, 2012, 01:03:44 AM »
Hi,

I am looking for the reverse one - from text to image converter.
When I look the email source that has image - it shows as in text format in source view.
I can edit that text and want to convert that edited text to image format - just want to edit the original image .
Is there any program exists ?

Thanks.

Nicolask3

  • Participant
  • Joined in 2005
  • *
  • default avatar
  • Posts: 2
    • View Profile
    • Donate to Member
Re: Tim - Image to Text Converter
« Reply #14 on: June 14, 2014, 12:25:02 PM »
Greetings,

The application looks great and I wanted to try but couldn't find the Borlan runtime components
Where can I find them?

Thanks in advance