Cody

# Problem 1199. ASCII art

Solution 198682

Submitted on 30 Jan 2013 by @bmtran (Bryant Tran)
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
%% chars=char([32:126,161:255]); bitmap=mean(double(imread('http://www.alfnie.com/software/monobitmap.bmp'))/255,3); bitmap=reshape(bitmap,size(bitmap,1),[],numel(chars)); img=imread('peppers.png'); img=sqrt(mean(double(img)/256,3)); img=img(1:floor(size(img,1)/size(bitmap,1))*size(bitmap,1),1:floor(size(img,2)/size(bitmap,2))*size(bitmap,2)); str=gray2char(img,chars,bitmap) assert(isequal(size(str),[14 36])); [i,loc]=ismember(str,chars); assert(all(all(i))); img=permute(reshape(img,size(bitmap,1),size(img,1)/size(bitmap,1),size(bitmap,2),size(img,2)/size(bitmap,2)),[1,3,2,4]); d=mean(mean(mean(abs(bitmap(:,:,loc)-img(:,:,:)).^2,3),2),1); assert(d<=0.11);

2   Pass
%% chars=char([32:126,161:255]); bitmap=mean(double(imread('http://www.alfnie.com/software/monobitmap.bmp'))/255,3); bitmap=reshape(bitmap,size(bitmap,1),[],numel(chars)); img=load('clown.mat'); img=mean(ind2rgb(img.X,img.map),3); img=double(img(ceil(.25:.25:end),ceil(.25:.25:end))).^.25; img=img(1:floor(size(img,1)/size(bitmap,1))*size(bitmap,1),1:floor(size(img,2)/size(bitmap,2))*size(bitmap,2)); str=gray2char(img,chars,bitmap) assert(isequal(size(str),[30 91])); [i,loc]=ismember(str,chars); assert(all(all(i))); img=permute(reshape(img,size(bitmap,1),size(img,1)/size(bitmap,1),size(bitmap,2),size(img,2)/size(bitmap,2)),[1,3,2,4]); d=mean(mean(mean(abs(bitmap(:,:,loc)-img(:,:,:)).^2,3),2),1); assert(d<=0.172);