Friday, February 27, 2015

Post #5. Some ascii art made in MATLAB

ASCII art is a text based artistic representation. It is possible to find incredible examples of ASCII art in the internet. There is lot of methods to create them. I developed an automated code to extract the spatial information of color from a picture file and insert it in a plot with some characters. Below, some examples of ASCII arts that I made in MATLAB codes. The basic idea of the ASCII art codes in MATLAB is to use a function named imread ( ). This function read .jpg, .bmp or .png files as matrix. After that,  I used a function named text( ) to plot the character using the color information from the graphical matrix. The code is too long, but below I wrote the fundamental steps:

I = imread(File); %This line read the picture as a matrix. File is the name of the picture address in your computer.

%The lines below shows how to plots the characters (in the example is the character 'x') using the colot information from the picture file. a and b variables are the units of spacing between the characters in the x and y axis, respectively.
[numrow,numcol] = size(I);
for i = 1:a:numrow
    for j = 1:b:numcol
            text(j,i,'x','Color',[I(i,j,1)/255 I(i,j,2)/255 I(i,j,3)/255],'FontName','Arial', 'FontSize',8);
   end
end





All the best,

Givago (givagosouza@gmail.com)

1 comment: