Code covered by the BSD License  

Highlights from
TEXT2IMAGE : Convert an ASCII text file to image

4.5

4.5 | 4 ratings Rate this file 72 Downloads (last 30 days) File Size: 153.41 KB File ID: #7952
image thumbnail

TEXT2IMAGE : Convert an ASCII text file to image

by Divakar Roy

 

30 Jun 2005 (Updated 27 Jun 2011)

Text to image conversion.

| Watch this File

File Information
Description

This code converts any ASCII text file (notepad, MATLAB-m files, etc) into images.

Screen shot is the image being converted from a notepad file that had the story - Christmas Carol.

MATLAB release MATLAB 7.11 (2010b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (8)
04 Jul 2005 Fahad Al Mahmood

Try replacing lines (52) and (53) with the following:
PathName=[pwd '\all letters\capital\'];
PathName=[pwd '\all letters\small\'];

14 Mar 2008 manish sardiwal  
14 Mar 2008 manish sardiwal

good software

22 Jun 2008 Arun Powar

very nice coding..

22 Aug 2008 ghini0n ghinion  
27 Jun 2011 David Smith

Can you give some example applications of this? I don't understand why anyone would do this.

That said, the code works nicely. It might be faster if you eliminated the strfind by converting the text data to ASCII codes and using those to index 'data_all'. Think of it this way, chars are already represented as integers in a standardized 256-element array (the ASCII char set), so there's no need to make your own array ('char_array_all') to index them.

Also, calculating the size of att2 and preallocating it might help. If that's too hard, guess its upper limit, then crop at the end.

27 Jun 2011 Divakar Roy

Hello,

First of all thank you for going through the code and putting up all those feedback.

I saw few files on MATLAB File-exchange and outside of it that convert images into ASCII text files. They gave those images fun-look.
The main intention when I made this code was to take a snapshot of those text files, so that one could see the whole text file without scrolling.

For more info please google for "text to image".

About using ASCII char set, yes that was one option, but then I am not using all the characters from the ASCII set, I am only using 95 ASCII characters, so even if I try to replace strfind, in the revised code I would have to still use
some sort of index finding method.

I followed your suggestion to do pre-allocation for att2, which gave me appreciable speed-up, so a big thank you to you! Pre-allocation won't be easy in the earlier part because of the variable nature of the sizes.

Thanks again!
Divakar

05 Jul 2011 Natalya

Thanks!!!

Please login to add a comment or rating.
Updates
06 Jul 2005

more realistic,new screenshot,bugs fixed

11 Jul 2005

all improved

01 Aug 2005

slight improvement

19 Sep 2005

converted to function format

29 Sep 2005

help is corrected

03 Jan 2006

Improved usability

11 Jan 2006

new screenshot

10 Aug 2009

90 % speed-up as a result of using mat files and removing loops.

24 Jun 2011

Rar file is replaced by zip file.

27 Jun 2011

Good speed-up after pre-allocation.

Tag Activity for this File
Tag Applied By Date/Time
fun Divakar Roy 22 Oct 2008 07:51:58
ascii Divakar Roy 22 Oct 2008 07:51:58
text Divakar Roy 22 Oct 2008 07:51:58
show Divakar Roy 22 Oct 2008 07:51:58
convert Divakar Roy 22 Oct 2008 07:51:58
image Divakar Roy 22 Oct 2008 07:51:58
ascii Hyunjoo ΓΌ 18 Mar 2009 20:55:42
ascii lev kadyshevitch 18 May 2009 17:23:43
bmp Divakar Roy 11 Aug 2009 10:49:06
jpg Divakar Roy 11 Aug 2009 10:49:07
largest Divakar Roy 11 Aug 2009 10:49:07
photo Divakar Roy 11 Aug 2009 10:49:07
ascii rizwan 14 Aug 2010 14:37:34
ascii Pawan Behera 21 Jan 2011 12:59:43

Contact us at files@mathworks.com