Create a pink noise image in Matlab

I would like to create a 2D image of arbitrary size containing randomly generated pink noise. Wikipedia suggests that a two-dimensional generalization of pink noise will have an energy that drops like 1 / f ^ 2. I found some code in the MATLAB file exchange that calculates 1D pink noise. But I do not know how to properly generalize it to two dimensions - I am not very familiar with fft, and my naive attempt below creates complex vectors when calculating ifft.

function pink = pinkNoiseImage(nrow,ncol) rnrow = 2.^(ceil(log2(nrow))); rncol = 2.^(ceil(log2(ncol))); r = randn(rnrow,rncol); rf = fft(r); rnup = rnrow/2+1; cnup = rncol/2+1; frf = kron(1./sqrt(1:cnup),1./sqrt(1:rnup)'); rf(1:rnup,1:cnup) = rf(1:rnup,1:cnup).*frf; rf(rnup+1:rnrow,1:cnup) = real(frf(rnrow/2:-1:2,1:cnup))-1i*imag(frf(rnrow/2:-1:2,1:cnup)); rf(1:rnup,cnup+1:rncol) = real(frf(1:rnup,rncol/2:-1:2))-1i*imag(frf(1:rnup,rncol/2:-1:2)); rf(rnup+1:rnrow,cnup+1:rncol) = real(frf(rnrow/2:-1:2,rncol/2:-1:2))-1i*imag(frf(rnrow/2:-1:2,rncol/2:-1:2)); pink = ifft(rf); 

How can I create a 2D matrix containing pink noise?

+2
image matlab fft noise
source share
1 answer

First, do not always believe what Wikipedia tells you. Or, read it carefully, because the definition of pink noise is not one for one for 2D. Secondly, you can use the following FEX file to generate 1/f^beta spatial noise with a normal error distribution. Read the documentation for this file for more details.

+3
source share

All Articles