看多了做数字图的东西,自己随便写了一个,挺简单的,纯娱乐。

digit0 = im2double(rgb2gray(imread('0.bmp')));
digit1 = im2double(rgb2gray(imread('1.bmp')));
digit2 = im2double(rgb2gray(imread('2.bmp')));
digit3 = im2double(rgb2gray(imread('3.bmp')));
digit4 = im2double(rgb2gray(imread('4.bmp')));
digit5 = im2double(rgb2gray(imread('5.bmp')));
digit6 = im2double(rgb2gray(imread('6.bmp')));
digit7 = im2double(rgb2gray(imread('7.bmp')));
digit8 = im2double(rgb2gray(imread('8.bmp')));
digit9 = im2double(rgb2gray(imread('9.bmp')));
digit = [digit0(:),digit1(:),digit2(:),digit3(:),digit4(:),digit5(:),digit6(:),digit7(:),digit8(:),digit9(:)];

img = im2double(rgb2gray(imread('input.bmp')));

sizey = size(digit0,1);
sizex = size(digit0,2);

x = 1;
y = 1;
for i = 1:size(img,1)/sizey
    x = 1;
    for j = 1:size(img,2)/sizex
        block = img(y:y+sizey-1,x:x+sizex-1);
        mink = 0;
        minval = 1000000;
        for k = 1:10
            val = norm(digit(:,k)-block(:));
            if val < minval
                minval = val;
                mink = k;
            end
        end
        img(y:y+sizey-1,x:x+sizex-1) = reshape(digit(:,mink),sizey,sizex);
        x = x + sizex;
    end
    y = y + sizey;
end
imshow(img);
imwrite(img,'output.bmp');

Sample

img

output