Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

New to MATLAB?

Solution 198682

Submitted on 30 Jan 2013 by @bmtran

Correct

101Size
Leading solution size is 83.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test
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);
str =
ÊÊÊÊÊÊÊÊÊÊÊÑÑÑÊÊÊÑÊÊÊÊÑÊÊÊÊÊÊÊÊÊÊÊÊÊ
ÊÊÊÊÑÑÊÊÊÊÊÑÑÑÑÑÑÑÑÊÑÑÑÑÑÊÑÊÊÊÊÊÊÊÊÊ
ÊÊÊÊÊÊÊÊÊÑÑÊÑÑÊÑÊÑÑÑÑÑÑÊÊÑÊÊÊÊÊÊÊÊÊÊ
ÊÊÊÑÊÊÊÊÊÊÊÊÊÑ°¯°ÑQÑÑÑÊÊÑQ¯ÑÊÊÊÊÊÑÑÊ
ÊÊÊÊÊÑÑÑÑÑQÑÑÊ¿_¸ÎÑÑ©QÑÊQQQÑQÊÊÊÑÑÑÊ
ÊÊÊÊÊÑÑÊQ©Q©ÊÊÊQÊQQQQÑÑÑÑÑÊÊÑÑλ»©QÑ
ÑÊÑÊÊÑQÑÑQQÊѯ¯Ñѯ¯¯¯ÑÑÑί¯·©ÑÑÑ©ÑÑÑ
ÊÊѯ¯ÑÊÑÑÑÑÊ©Qg¨    ``QQÿ»»QQQQQQQQÑ
ÊÊ»».QÎ^¨¨°ÜQQÑ» ¸_¸»QÑÑÑQQÑÑÑÑÑÊÊÊÊ
ÊQQQQQQ»»:·³ÑQQÿ_»QQQQþÑÑÑÑÑÑÑÑÑ ¾ÊÊ
ÊÑ`¯°ÑQQÿ.Q» `ÑÑÜÜqQQQQÊÊQQQQѯ    ¯
ÑQQQQQÊØ®Q__QØÊÊÊÊÑÑÑÑÑÑÑÑÊÊÊþ__  __
ÑÊÑQÊÊÊÑÑÊÊÊÊQQQQQQQQQQQQQQQQQÑÊÊËÊÑ
ÑÑÑÊÊÊÊÑ©ÑÑÑÊÊÊÊÊÑÑÑÑÑÑÊÑÊÊÊÊÊÊÊÊÊÊÊ

	    	
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);
str =
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯*¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
                             `«        »9ª¨              ¯"²²QQ__````.`      ·` · `      ``
                    `        `·      «¨                       ¯ÛÃÑqq»·         .·
                             »      `                             ¯ÑQ´·      `
               ¿.`__«       :*     `                  _¸_             »».        .`` ·
                ´¯¯Î¨¨¨»:.  !`    :´                 ¸ÑQÑÿþ        ```³¼ »     ´`;````` ```
»·                    ¸¨´Q_.     ³²         ..¸»·   ´7ÑÊËÑÑ      .. ``  `«·`  `   ·     `·.
Ñ»                    ΩØÊÊÜ:    Ñ          _¸..  ´  _QÑû       ¸       `»``¸¸`:·· `     ·
þ»`¸           .`      ²«».æ²   i¯  ¸¡»©»»»«``:·¸;¯ .ýÂÑÊ       .`    ·«».`¨`»»¨`.`   `   `
j©Ñ                            ¸Î  Q©ÑÑQ©²   .··^°¯¯¯¯®®¿¿¸ `  .»¸«»¸»½``.·»»»`·  ·  ``   ·
©¨: ·            ·            ¡Ñ  «ÑÑÑÑܯ`     ,»«ùq¿¿»^,¯¨»``¨QQQjÑ©ÑÜ»`²»``«©»»«:·``  ``»
Qÿ"  ·            »          ¸QÑ»Q»Üî··`   ¬«»»³     ,MÊQþQÿ»»`;©ÑÑQQQÑQ©Q©ù»3½Ñ®´¨``  ·  ·
ÊÎ2`              ·²       ¸«qÊQ©©»`                ¡,ÆÑÊþHþêQØQQ©ÑÑÊ©ÑÑ©»2Q©QQ2«»»```  ``
þgQþ»``  ·;.       ´      `QQÆÊQÎ`·                 ³©ÑÛÊÎQÊÆQÑqQQÑÑÊÑÑÑÎÎQQ©©ÑgQ©»»:``` ``
®®Êp_ÑQ_Qý©©`¸ ```¨·;.  ¸«QØÊÊÑÊþ_                    ÛÊØÑÑÊÊÑ©¯¯ÎÑÑÑÑÑÑÎÎQQ©QËÊØÑÿ,±``¨¸¸.
ÊÊpÊÊQÊÿѯ```.·`:.·```»»`©ÑÑÊÑÑÑÊÊp¿¸               ¸¸·_Q»QgQ®½»»´^^²»¨²©ÊÊÊÊÊÊÊQ®Ñ©`»·`,;^
ÊØÊÊÊÊÊÛ::·      ·»«:;»«:»»ÑÑÑÑÑÊÊÊÑÊQQ_            `¨ÜѩܯÜ©«»2`````¸¯ÛÑÊÊØËqʽ©»,»«:»»
ÊÊÑÊÊÊÑ````      :»»»»QQ©©QQQQÑÑÑÊÑÑ©ÑÑÑ®¿     ¸¿«g®¿gQQ¿ggpggQQ¿¿_¸¸²·´:¸²ÑÆÊÊÊþ¯`»î²»·»»½
ÊÊÑÊÊÊ«»``     .»i»»»îÑ©©QQQ©ÑÑQÊÑÑþ©©:` ³©» «Q»^²¨¨´¯¯°¯¯¯Û¯ÛÛÊÑÑÑÊÆgp_»©ÑQÊÊÊQ©©Ü³`,«·``«
ÊÊÊÊÊÊþ«::»»:»»»»»úù©©ÑQÑÑÑÊÊQÑÑÊÑÑþÊ©»    ``               `¸·`;©©ÑÑÊÑÊÊgpQØÊþþ®©»»`©Q`»`¨
ÊÊÊÊÊÊþQ»»»«»»QÑÑ©ÑQQQQÑÊÊÊÑÊØÑÑÊQÑÊþþQ`                 ·`«²»»QQ©QÑ©QQÑÊÊÊÊÊÊÊÑÊÿQÑQQ©QQ»¸
ÊÊÊÊÊÊÊþÿ©ÑQ©©ÑQQQÑÑÊÿÑÊÊÊÊÊÊÊÑÊÊÊÊÊÊÊÑp_                ``»»ùQQ©ÑÑÑQÊQÊÆÊÊÊÊÊÊÊÿÑÑQ©ÎQÑÎÎÑ
ÊÊÊÊÊÊÊÊÊQþÑ©ÑQÑÊÑÑÑØÊÊØÊÑÑÊÊÊÊÊÊÊÊÊÊÑѯØÑþ¿¸       ` .:`i«©½QÑQ©©ÑÊQÑÑÊÊÊÑÊÊÊÊØÊÑÑÜQQÑ»©©Ü
ÊÊÊÊÊÊÊÊÊÊÊþQÿÑÑÊÊÑÑÊÊÑÑÊÊÑÑÊÊÊÊÊÊÊÊÊÊþQ  ¯ÛÑQ¿¸  `»;»»©QQQQ©ÑÑÑÊÑÑQQ®ÆÑÊÊÊÊÊÊÊÊÊÑÑÑ©©Ñ©QQ©
ÊÊØÊÊÊÊÊÊÊÊÊÊþ       ´¨ÑÑÊÊÊÊÊÊÑÊÊÊÊÊÊÑÑ«;¸  ¯ÛÑQp_Q©QQQQQQQQÊÑÑÊÊØÑÊØÊÑÊÊÊÊÊÊÊÑÊÊMÑQøÑQQQQ
ÆÊÊÊÊÊÑÊÊÊÊÊÊÊþ         ¨ÎÑÊÊÊÊÊÊÊÊÊÊÑÑÑΩ»»».  ¯ÊÑQpÿÑËÊQÑÊÊÊÑÊÊþÑÊÊQÊÊÊÊÊÊÊÊÊÊÊÊÊQQþÑQÊÛÑ
ÆÊÊÊÊÊÑÊÊÊÊÊÊÊÑp ¸¨»,¸    ¨Î©ÑÑÑØÑÑÑÑÑÑ©QQQ»;ù3»: :¯ÊÊÊÊÊÑÊÊÊÊÑÑÊ®ÑÊÊÊÊØÊÊÊÊÊÊÊÊÊÑÊÊÊÊÊÊQQÑ
ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊþ ²»``²Ñ©QQQ¿Q_jQÑÑÑ©QQÑQQ®ggQ®QQ;`·`²QÑÊÊÊÊÊÑÑÑÑÑÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÑÑÊQÊÊ
ÊÊÊÊÊÊÊÑÊÊÊÑÊÊÊÊ  ·`:»»«QÎÑÑÑÑÑÑÑÊØÊÊÊÊÑÊÊÊÊÊÊÊÑÿ¿`.ÎÑÑÊÊÊÊÑÑÑ©ÑÑÊÑÑÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ
ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ     `^Ñ©©QQÊÑÑÑÊÊÑÑÊÊÊÊÊÊÑÊÊÊÊÑÊÑþ ·ÑÑQÊÊÊÑ©½©ÑQÑÊÊÊÊÊÊÊÊÑÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ