<span style="font-size:18px;">I=imread('C:/Users/liwei/Desktop/bg.jpg');%读入图像
figure, imshow(I);%显示去水印前的图像
t =I(220:270,200:400,1:3);%大致估计水印区域
figure, imshow(t);t1 = t(:,:,1);%抽取原图像r的R,G,B的其中一维得到灰度矩阵figure, imshow(t1);t2 = t(:, :, 2);figure, imshow(t2);t3 = t(:, :, 3);figure, imshow(t3);[m,n] = size(t2)for i = 1:mfor j = 1:nif t2(i,j) >= 190t2(i,j) = 170;endend
end
figure, imshow(t2);for i = 1:mfor j = 1:nif t3(i,j) >= 190t3(i,j) = 170;endend
end
figure, imshow(t3);for i = 1:mfor j = 1:nif t1(i,j) >= 190t1(i,j) = 170;endend
end
imshow(t1);for i = 1:mfor j = 1:nt(i,j,1) = t1(i,j);t(i,j,2) = t2(i,j);t(i,j,3) = t3(i,j);end
end
figure, imshow(t);for i = 1:51for j = 1:201I(i + 219, j + 199, 1:3)=t(i, j, 1:3);end
end
figure, imshow(I);</span>
http://www.mamicode.com/info-detail-1112600.html