image thumbnail
from ECard using Scientific Tool by Tan Chin Luh
This is an ecard inspired by a new year greeting email.

NY
function NY
IW = [2.39659457189773,1.07694247013609,-1.62596541138854,-3.38031465751801,2.14442776996772,-2.03010719069914,0.0463113443552914,0.852788297731691,1.47679107319135,-1.49900843257256,0.573777014977627,-1.05345386491355,0.129639999133938,-2.15150238156919,0.864234351666376,0.206337187835506,0.739133262684127,-1.05898740634775,-1.88089712677846,-0.772755191167343,0.357212282029549,2.67206667246180,-1.66655789449791,-0.538746657073159,-0.745509471355352,-0.728215436369330,-0.269779736161276,0.687582605440383,0.518775766307867,-1.69655754300259,-0.758561112256511,-0.0262687345564848,0.745754533249517,-0.973225754695968,0.520375985991398;-0.479067099213551,1.46531267862643,-0.610295347816492,1.32097272245080,-1.34660662919629,0.811538838391761,1.68859512043581,-1.65652785555095,1.12413506622315,-1.32429908004194,-1.16691359151646,-1.73563540290596,-1.57391976850506,0.458573785966563,-0.484873734450327,-2.55425174720741,-2.78002173999081,0.139555954398437,-0.695919417753333,-1.28857124380830,-1.87533845264687,-1.21222174958465,1.65657717461663,0.219044658700059,-3.11261682722726,-2.45862245418832,1.97863767974954,0.872724209751875,-1.74172264681412,-0.537947430035664,1.07714940970442,1.35550312269989,-0.501658379426127,-0.334621366287644,0.0182684170167635;0.630157981248157,1.96605251710165,1.43740973019949,-0.672340127320403,0.484838807000971,-0.628292262406014,1.43847325642096,1.15639649168625,-0.455717154215543,1.56216750391839,-0.435471666224049,0.992836603337486,1.44326827754803,-1.63487120395972,0.970788778117945,-2.23016615625319,-3.44434495768421,-0.897327186264324,1.35652482360227,-1.50460859253493,-2.11951102368347,-3.05307871676039,-0.434667354515811,0.572691736647640,1.05145301262454,0.747866971232526,-0.704960649747643,-0.492411635312315,1.41637456758543,-0.732205708230207,-0.503156515150012,1.45853464882060,2.46196625166971,-0.211042976735747,-0.550108842062532;-0.371438513826246,0.0270756643634425,-3.19231032309168,3.39079402846925,-0.0575312429480449,-0.288166239730364,0.669329084513207,0.917405741318238,1.10866618100572,-0.944412772549303,-1.74782956353894,-0.0422646949404568,-1.84102150888013,3.56976893698673,0.660696344063592,-1.64273389740246,-2.46224965313848,-0.370389490673790,2.06398335324546,-1.80239744822746,-1.19981145464522,0.553548137581011,2.08245341845741,1.23065576307998,-0.496282963427410,0.287065774072643,0.573935917877523,0.544338018697154,-0.820157556847881,-1.70977776489958,0.821134166880836,-2.13021250041639,-2.29858525534172,1.02132198671311,2.09430647710648;1.65037874942588,-1.00955276769712,-2.28338200483404,0.0245884456392701,2.80014263881303,-1.01862127113406,2.45666138162681,-0.130766085108827,-2.00519105369983,-0.393627269305960,0.977638317535707,0.404338207391930,1.45781894192072,1.71684613011462,-0.672262594066933,-2.17598380747787,-0.628762567500930,-1.55246804837247,-0.740970592192101,1.86788911643742,-1.92787536838065,-2.32051397988590,0.275284106988404,0.229854419136301,2.73422588999090,1.13923252772837,-2.33241995459265,0.469213737078406,-0.540086964955710,0.837293574406163,-2.20386014727485,1.53376245358496,0.147972491309352,0.200020358580073,0.965542328397142;1.51401403057989,-0.112864228200612,-1.29321721742708,-0.523481523156636,-0.428812894655878,0.691141492423727,-0.448880231916693,1.04739207899514,2.50202920373634,0.396880627014689,-2.25321761869842,-0.0829202742833865,2.47927787292979,-0.431167526510235,-2.30609941560907,-0.559187120277392,-2.10498750695250,0.782586886391871,-1.18032483663961,-2.00397261425524,0.332300886754580,0.627649096541636,0.979358685139099,0.0343362830818573,0.102935958291665,2.22895624757172,0.235404650248348,2.02912108680674,1.08422749718272,1.05420380640721,0.612016744750235,1.80677089579745,-1.13272778611694,-1.55062973076125,-2.43893797130636;-0.495237719891383,1.37228805972350,-1.52036343240167,3.22830892828669,0.618701686160213,-0.954436547924408,-0.528531371455703,-0.283949988748426,-2.21588529468356,-1.67800935805811,0.579514547164283,1.01575741294609,3.76068160896639,1.39040927812016,-1.71110694442109,1.08015721920003,-0.0431316106722628,0.613478483948148,1.32553779323279,0.0725923628990666,-0.0348595774523303,2.11375353772745,-1.85411906881806,-0.312607361918651,-0.299438270108860,1.49782095296414,2.08828681355290,-0.900775053529379,1.45641246003777,1.18267017051609,0.613171260539825,0.0352996291612329,1.90459418037478,1.41360976885278,-1.87421720309588;-1.38362170883965,1.74620302436842,0.555841223398556,-0.123736817897984,-0.272695283844679,2.40953360502503,-0.674947483062511,-0.562077290228881,-1.07394944815839,0.304434477371772,0.978466664075468,-1.00147425276340,0.289908873160826,-2.09758737735822,0.313309166640762,-3.00497155685701,1.38574672023404,2.73222252037799,-0.915484280472527,-3.06026942306384,-1.28124412203822,0.829440927682078,-2.64001286023638,-0.283689630342296,-1.13650734114183,0.670763733223083,-0.514998982988306,-0.830497780122229,1.31870049334920,2.25687993836007,2.42203316464548,-1.07610630202135,-0.611836961036543,0.640904490977755,-1.08594794197426;0.989903502251570,-1.02895306275124,-2.13016004779305,-3.48239810216493,-1.14367536363192,1.59290935704311,-1.18259088129850,0.512068361877042,0.742748355883964,-2.09000133396041,-0.431166331741664,0.0663436322979968,-0.934260533032434,-1.33013600021657,-0.963075677160392,-2.49073672841931,0.719833120810026,-0.126087953236531,0.637004874121490,-2.13569615386476,-0.511971709656333,1.19535097782109,-1.78832052097319,0.797497508579807,-0.358458639107370,0.106411285053033,0.118625758587161,0.255978713676712,0.0893330749829582,1.33861272648240,1.12651957201408,0.727140231103365,0.0610206627261119,0.508022524008695,-0.582233479531943;0.200047163623755,1.53720658827744,-1.51936114342748,1.03240118883675,-0.596190969830254,-0.132082772178629,-0.293417058209655,0.762881467292490,1.77625574692481,3.08953905160932,-0.0438313090494362,-2.27370487144073,-0.376250193211373,3.80561734469182,0.510166130206468,0.925277986862687,0.113997132519699,0.451713773633489,1.76848477086946,2.05081551367047,3.43018451405641,-2.49144238427665,-4.84097811442062,-0.639683481497127,2.92905571473724,2.01515583493826,-0.0473779854907562,0.116943023690068,0.816481390588568,-0.743008230801217,0.543358074254850,-1.83010992885311,-2.69167024050344,0.509178863897436,0.191971151489865;];
LW = [-0.613786744970604,-2.07477023223615,-0.991833244311019,3.13314841711608,5.35734527163965,-2.10858909715284,-3.41730808681456,-2.33793617910954,-1.69354544414345,2.66419178412811;-1.00499790505374,5.26220521879749,0.490121513306433,4.39065614390600,-3.07905336331130,-2.66101791812228,-3.29225996765602,-1.92526969348324,-1.58221853965779,-3.88667310260511;-3.53166132185691,-2.04689516877593,4.18695363450989,-2.55620825611764,-0.467350742908166,3.90129957790074,-3.51312285679929,1.13951083343526,-1.11110898647575,2.21627337516922;-1.88231428650847,-2.26075375180812,-1.96488686950046,3.33566094378894,-3.32678926079008,4.85939461542020,2.99684276233032,-2.28767905092352,-1.32467276798682,-3.63392842787591;-0.881736368993031,-1.74143057798853,5.22171950221281,-2.23624737252034,4.15910829315577,-1.71940837302435,2.08967904191138,-0.337722787037627,-1.62826562046708,-3.42688652275883;-0.537955739433467,-1.75574647622354,-5.68172729902467,-3.69665978869275,-0.341528554377607,-2.50110628271717,7.12915327095527,-2.37505800134894,-1.35207791113747,-0.961112238799527;4.71621127001265,0.969595806517960,-3.38012830395006,-2.16662293340807,0.286545162328697,3.87973450447946,-1.93124809020341,0.182015086128213,-1.91086801218047,-3.79656914636587;-2.25974512317237,-2.10866716353390,-0.830163567838418,-0.673980151667802,-2.72189158796535,-4.06656732600197,-2.32967276368366,7.69382692397019,-0.454070458696139,-2.62235461433498;-0.885110966592212,-2.57300832602223,-1.55549834461114,-2.48915924166005,0.462531558162838,-2.13558941901048,-3.89985891980543,-4.16434443935219,-1.43740636693268,-5.88571227121813;0.800360671806365,-2.19071676913302,-2.64403491685794,-3.42800641859701,-3.87329839993393,-1.73914114727791,-3.02609159066474,-4.07265703177847,-1.12478122818680,5.37581401679519;];
b1 = [5.89096720772885;3.79560460130111;-4.12451587620422;-3.06408364152641;1.25502882145339;-0.148875004577086;-11.0672272093322;1.66912909482421;-1.01181946100122;-7.42544020402597;];
b2 = [-6.06319479771526;-3.18670251627107;-5.99504995860567;-4.59192017570535;-7.23798149906226;-3.15524731210298;-5.15076479119713;-1.75423464134556;3.17905421837658;-1.86769600389106;];

S = imread('NY.jpg');
S2 = im2bw(S,0.5);
S3 = ~S2;
S3 = imdilate(S3, ones(2));
[S4,num] = bwlabel(S3);
S2p = imresize(S2,0.5);
h = imshow(S2p);

for cntsub = 1:num

            Stemp = (S4==cntsub);
            [x,y]=find(Stemp);
            BB = [min(y),min(x),max(y)-min(y),max(x)-min(x)];
            I{cntsub} = S4(BB(2):BB(2)+BB(4),BB(1):BB(1)+BB(3));
            I1 = I{cntsub} ; 
            I2 = 1-I1;
            lett = cl_imgresize(I2);

            lett2 = IW*lett + b1;
            for cnt = 1:length(lett2)
                lett3(cnt) = 1 / (1 + exp(-lett2(cnt)));
            end
            result = LW*lett3'+ b2;
            

            [n,d] = max(result);
            if d==6;
                aaa = round(BB);
                S2(aaa(2):aaa(2)+aaa(4),aaa(1):aaa(1)+aaa(3)) = 1;
            end
            
            clear Sprop dist;
            pause(0.01);
            S2p = imresize(S2,0.5);
            set(h,'cdata',S2p*63);
            

end




function lett = cl_imgresize(bw2)

bw_7050=imresize(bw2,[70,50]);
for cnt=1:7
    for cnt2=1:5
        Atemp=sum(bw_7050((cnt*10-9:cnt*10),(cnt2*10-9:cnt2*10)));
        lett((cnt-1)*5+cnt2)=sum(Atemp);
    end
end

lett=((100-lett)/100);
lett=lett';        

Contact us at files@mathworks.com