用matlab生成干扰图片(颜色块随机矩阵):
img = reshape(1:256,16,16);
image(img);
axis square;
axis off;
for i =1:200
paintpots = rand(256,3);
colormap(paintpots);
drawnow;
end
棋盘格的生成:
[x,y] = meshgrid(1:600,1:600);
x1 = sin(x/10);
y1 = sin(y/10);
c = x1.*y1;
pic = c>0;
imshow(pic);
马赫带的生成:
img = 1:10;
figure(1);
paintpots = ones(10,3);
colormap(paintpots);
image(img);
axis off;
for i =1:10
paintpots(i,:)=(i/10);
colormap(paintpots);
end
对图片去水印:
im = imread('shuiyin.png');%需要去水印的图片
g = rgb2gray(im);
d = im2double(g);
y = d*1.7-0.3;
imshow(y);
如图,左为水印图,右为去除后的效果。
若要将处理结果输出为图片,可在代码末尾加入一行imwrite语句。
所有代码引自 陈立翰《心理学研究方法——基于MATLAB和PSYCHTOOLBOX》,该书详细讲解了用matlab进行心理学视觉、听觉刺激呈现的程序编写及反应收集,需要可自行购买。