%%% Diffuse
%%% 扩散效果
clc;
clear all;
addpath(‘E:\PhotoShop Algortihm\Image Processing\PS Algorithm‘);
Image=imread(‘4.jpg‘);
Image=double(Image);
size_info=size(Image);
height=size_info(1);
width=size_info(2);
Filter_size=7;
sigma=Filter_size/6;
F_gaussian=fspecial(‘gaussian‘, Filter_size, sigma);
% 利用邻域的任意一点代替当前像素点
N=3;
Image=imfilter(Image,F_gaussian,‘conv‘);
Image_out=Image;
for i=1+N:height-N
for j=1+N:width-N
k1=rand()-0.5;
k2=rand()-0.5;
m=(k1*(N*2-1));
n=(k2*(N*2-1));
h=floor(mod(i+m,height));
w=floor(mod(j+n,width));
if w==0;
w=width;
end
if h==0
h=height;
end
Image_out(i,j,:)=Image(h,w,:);
end
end
imshow(Image_out/255);
原图
效果图
时间: 2024-10-09 04:04:32