Graphics Note

random phase noise

앨리삵 2014. 12. 10. 15:11

텍스쳐 합성에 random phase noise라는게 나와 구현해봄.


function rpn = genRPN( img )

% Generate Random Phase Noise associated with a given square-sized image 'img'

    [sz, ~, chsz] = size(img);

    hsz = floor(sz/2+1);

    

    h_theta = unifrnd(-pi, pi, [sz, hsz]);

    h_theta(1,1) = 0;

    h_theta(hsz,1) = randsample([0, pi], 1);

    h_theta(1,hsz) = randsample([0, pi], 1);

    h_theta(hsz,hsz) = randsample([0, pi], 1);


    theta = [h_theta(:,1:end-1), rot90(h_theta,2)];

    

    rpn = zeros(sz, sz, chsz);

    fft_img = fft2(img);

    e = exp(theta * 1i);

    for ch=1:chsz

        rpn(:,:,ch) = real(ifft2(fft_img(:,:,ch).*e));

    end

end


이미지의 위상을 균일 난수만큼 이동시켜서, 비슷하지만 서로 다른 텍스쳐를 생성할 수 있는데, 가우시안 텍스쳐가 아니면 썩 좋지 못한 결과를 보인다. 왼쪽 위가 원본 텍스쳐고, 나머지 세 개가 위 코드로 생성한 텍스쳐이다.


 


  

참조한 논문들

Bruno Galerne, Yann Gousseau, and Jean-Michel Morel, "Random Phase Textures: Theory and Synthesis, IEEE Transactions on Image Processing, voㅣ. 20, no. 1, pp. 257-267 2011


J.-P. Lewis, "Texture Synthesis for Digital Painting", in Proc. SIGGRAPH, New York, 1984, pp. 245-252.