博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

在图像中随机更改像素值程序——matlab

Posted on 2017-11-09 18:31  warmbeast  阅读(1660)  评论(0编辑  收藏  举报
I=imread('C:\Users\wangd\Desktop\result3.png');
% m = rgb2gray(I);
% r = unidrnd(255,1,100); %产生一个1*100的数组,数组中的值为1至255中的随机值
% r1 = randi([2,7],10,100); %在开区间(27)生成10 * 100型随机矩阵
subplot(2,2,1);imshow(I);
title('原始图像');
for w=1:200
    j= randi([1,350],1,1);
    i= randi([1,400],1,1);
    x= randi([200,255],1,1);
    I(j,i)=x;
end
subplot(2,2,2);imshow(I);
title('图像');
imwrite(I,'C:\Users\wangd\Desktop\1.png');