%%%% Cloud%%%% 利用perlin noise生成云彩clc;clear all;close all;addpath('E:\PhotoShop Algortihm\Image Processing\PS Algorithm');Image=imread('4.jpg');Image=double(Image);[row,col,layer]=size(Image);baseNoise=rand(row,col);persistance = 0.9;totalAmplitude = 0.0;octaveCount=10;Cloud_texture=zeros(row,col);for i=0:octaveCount amplitude=persistance.^(octaveCount-i); % amplitude=persistance.^i; totalAmplitude=totalAmplitude+amplitude; Cloud_texture=Cloud_texture+Generate_smoothnoise(baseNoise,i)*amplitude;endCloud_texture=Cloud_texture/totalAmplitude;imshow(Cloud_texture); function SmoothNoise=Generate_smoothnoise(baseNoise,octave)SmoothNoise=baseNoise;[row,col]=size(baseNoise);samplePeriod=2.^octave;sampleFrequency=1/samplePeriod;for i=1:row sample_i0=floor((i/samplePeriod))*samplePeriod; sample_i1=mod(sample_i0+samplePeriod,row); vertical_blend = (i - sample_i0) * sampleFrequency; for j=1:col sample_j0 = floor(j / samplePeriod) * samplePeriod; sample_j1 = mod(sample_j0 + samplePeriod,col); horizontal_blend = (j - sample_j0) * sampleFrequency; if(sample_i0<1) sample_i0=1; end if(sample_i1<1) sample_i1=1; end if(sample_j1<1) sample_j1=1; end if(sample_j0<1) sample_j0=1; end % blend the top two corners top = Cosine_Interpolate(baseNoise(sample_i0,sample_j0),... baseNoise(sample_i0,sample_j1),horizontal_blend); % blend the bottom two corners bottom = Cosine_Interpolate(baseNoise(sample_i1,... baseNoise(sample_i1,horizontal_blend); % final blend SmoothNoise(i,j) = Cosine_Interpolate(top,bottom,vertical_blend); endendfunction y=Cosine_Interpolate(x1,x2,Alpha)ft = Alpha * 3.1415927;f = (1 - cos(ft)) * .5;y=x1*(1-f)+x2*f;
原图
效果图
总结
以上是内存溢出为你收集整理的利用Perlin nosie 完成(PS 滤镜—— 分成云彩)全部内容,希望文章能够帮你解决利用Perlin nosie 完成(PS 滤镜—— 分成云彩)所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)