码迷,mamicode.com
首页 > 其他好文 > 详细

利用perlin noise 生成 wood texture

时间:2015-03-28 18:46:40      阅读:226      评论:0      收藏:0      [点我收藏+]

标签:应用   算法   photoshop   

%%% 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

标签:应用   算法   photoshop   

原文地址:http://blog.csdn.net/matrix_space/article/details/42215511

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!