topbanner_forum
  *

avatar image

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

Login with username, password and session length
  • Saturday November 9, 2024, 7:25 am
  • Proudly celebrating 15+ 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 61764 times)

TPReal

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 129
    • View Profile
    • Donate to Member
Tim - Image to Text Converter
« on: December 28, 2007, 01:58 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.

Tim1.jpgTim - Image to Text Converter
Tim2.jpgTim - Image to Text Converter
« Last Edit: January 29, 2019, 08:36 AM by wraith808, Reason: Corrected attachments »

tomos

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

CodeTRUCKER

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,085
    • View Profile
    • Donate to Member
Re: Tim - Image to Text Converter
« Reply #2 on: January 01, 2008, 01:00 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 PM by CodeTRUCKER »

TPReal

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 129
    • View Profile
    • Donate to Member
Re: Tim - Image to Text Converter
« Reply #3 on: January 02, 2008, 03:45 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++ [Select]
  1. im->Canvas->Font=font_you_use_for_conversion;
  2. int width=im->Canvas->TextWidth('x'),height=im->Canvas->TextHeight('x');
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++ [Select]
  1. im->Canvas->TextOutA(10,10,ch);
  2. int counter=0;
Then in loop where i changes from, say, 0 to width+10 and j from 0 to height+10:
Code: C++ [Select]
  1. counter+=im->Canvas->Pixels[i][j]&0x0000FF;
Finally, the density of ink for this character is:
Code: C++ [Select]
  1. 1-(double)counter/255/width/height
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,085
    • View Profile
    • Donate to Member
Re: Tim - Image to Text Converter
« Reply #4 on: January 02, 2008, 03:51 AM »
Thank you for the explanation.  I learned something! :Thmbsup:
« Last Edit: January 22, 2008, 06:56 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 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 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: 129
    • View Profile
    • Donate to Member
Re: Tim - Image to Text Converter
« Reply #7 on: January 15, 2008, 10:56 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 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: 129
    • View Profile
    • Donate to Member
Re: Tim - Image to Text Converter
« Reply #9 on: April 10, 2008, 12:02 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: 59
  • hey!
    • View Profile
    • Personal Website
    • Donate to Member
Re: Tim - Image to Text Converter
« Reply #10 on: April 02, 2009, 05:47 AM »
It's nice.. haha... I like this program.. So it's written in C Language? did u make this?...

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 AM »
it isnt working :|

jeremejazz

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 59
  • hey!
    • View Profile
    • Personal Website
    • Donate to Member
Re: Tim - Image to Text Converter
« Reply #12 on: October 26, 2009, 04:42 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

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 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 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

chashnniel

  • Member
  • Joined in 2018
  • **
  • default avatar
  • Posts: 127
    • View Profile
    • Donate to Member
Re: Tim - Image to Text Converter
« Reply #15 on: January 29, 2019, 12:23 AM »
the download link is broken
what kind of dll files do i need to put into the prog folder?

TPReal

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 129
    • View Profile
    • Donate to Member
Re: Tim - Image to Text Converter
« Reply #16 on: January 29, 2019, 03:25 AM »
Sorry, I don't remember this now, I haven't used C++Builder in a very long time... But if you try running the program, it will tell you the first missing one, I think, maybe it can be found somewhere.