摘自
clear;clc;m1 = [[0 2];[3 1]];u1=ones(2, 2);m2=[[4*m1 4*m1+2*u1];[4*m1+3*u1 4*m1+u1]]u2=ones(4, 4);m3=[[4*m2 4*m2+2*u2];[4*m2+3*u2 4*m2+u2]]I = imread('E:\\beichuan1.jpg');gI = .2989*I(:,:,1)... +.5870*I(:,:,2)... +.1140*I(:,:,3);[h w] = size(gI);bw = 0;for i=1:h for j=1:w if (gI(i,j) / 4> m3(bitand(i, 7) + 1, bitand(j,7) + 1)) bw(i,j)= 255; else bw(i,j)= 0; end endendimshow(bw);