%%% Perlin Noise %%% Wood_texture clc; clear all; close all; addpath('E:\PhotoShop Algortihm\Image Processing\PS Algorithm'); Image=imread('9.jpg'); Image=double(Image); [row,col,layer]=size(Image); baseNoise=Generate_basenoise(row, col); persistance = 0.5; octaveCount=6; Cloud_texture=Cloud_generate(baseNoise,persistance,octaveCount); % figure, % imshow(Cloud_texture); turbePower=0.45; period=10; Center_X=(col+1)/2; Center_Y=(row+1)/2; Wood=zeros(row, col); for i=1:row for j=1:col xValue=(j-Center_X)/col; yValue=(i-Center_Y)/row; distValue=sqrt(xValue*xValue+yValue*yValue)+turbePower*Cloud_texture(i,j); Wood(i,j)=abs(sin(2*period*distValue*pi))*128; end end figure, imshow(Wood/128); Image_new=Image; Image_new(:,:,1)=uint8(Wood+80); Image_new(:,:,2)=uint8(Wood+30); Image_new(:,:,3)=uint8(30); figure, imshow(Image_new/255); %%% Cloud generate function Cloud_texture=Cloud_generate(baseNoise,persistance,octaveCount) [row, col]=size(baseNoise); Cloud_texture=zeros(row,col); totalAmplitude = 0.0; for i=0:octaveCount amplitude=persistance.^(octaveCount-i); % amplitude=persistance.^i; totalAmplitude=totalAmplitude+amplitude; Cloud_texture=Cloud_texture+Generate_smoothnoise(baseNoise, i)*amplitude; end Cloud_texture=Cloud_texture/totalAmplitude;
效果图
利用perlin noise 生成 wood texture
原文地址:http://blog.csdn.net/matrix_space/article/details/42215511