用Mathematica绘制字符图的方法
1、把图片灰度化:
pic = ColorConvert[pic, "Grayscale"]

2、缩小图片:
pic = Thumbnail[pic, 100]

3、把图片转化为像素数据:
data = ImageData[pic];
% // MatrixForm

4、给出字符串:
zfs = {"+", "-", "*", "/a", "b", "c", "d", "e", "f", "g", "h", "i",
"j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v",
"w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8",
"9", ".", ",", "?", "@", "#", "%", "&"};
用这些字符串来代替小图片的像素。
自定义一个像素数值与字符的匹配函数:
match[c_] := zfs[[IntegerPart[c*100/2.5 + 1]]];
匹配:
Grid[Map[match, data, {2}], Spacings -> {0, 0}]// Rasterize

5、字符串的顺序改一下:
zfs = {"1", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p",
"q", "r", "s", "t", "u", "w", "x", "y", "z", "0", "+", "-", "*",
"/a", "b", "c", "d", "e", "2", "3", "4", "v" "5", "6", "7", "8",
"9", ",", "?", "@", "#", "%", "&", "."};
匹配函数改一下:
match[c_] := zfs[[IntegerPart[c*100/3 + 1]]];
