matlab是一个非常好用的数学软件,我们也可以利用matlab对图像进行处理。
利用matlab给彩色图像打上马赛克:
clear all;clc;
a=imread('123.jpg');
figure(1),subplot(1,2,1);imshow(a);title('原图像');
for b=1:3
I=a(:,:,b);
for i=1:10:991
for j=1:10:991
B=I(j:j+9,i:i+9);
average=floor(sum(sum(B))/100);
for k=0:9
for g=0:9
I(j+k,i+g)=average;
end
end
end
end
gary(:,:,b)=I;
end
figure(1),subplot(1,2,2);imshow(uint8(gary));title('马赛克图像');
这样就可以得到打上马赛克的图像了