利用perlin noise 生成 wood texture

%%% 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_第1张图片

你可能感兴趣的:(算法,应用,photoshop)