how do i create 1/f visual noise on matlab
17 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
how do i create 1/f visual noise in matlab
please help
0 commentaires
Réponses (1)
Leepakshi
le 5 Mar 2025
Modifié(e) : Leepakshi
le 5 Mar 2025
Hello Bhagya,
1/f noise often referred to as "pink noise", has a power spectral density inversely proportional to the frequency.
Please refer to the following MATLAB Answers post regarding the generation of 1/f noise using MATLAB:
But it only plots the pink noise. If with “visual” you mean pink noise in image, please proceed with the following steps in MATLAB.
% Define the size of the noise image
imageSize = [256, 256];
% Create a grid of frequencies
[u, v] = meshgrid(1:imageSize(2), 1:imageSize(1));
u = u - mean(u(:));
v = v - mean(v(:));
% Calculate the frequency magnitude
freqMagnitude = sqrt(u.^2 + v.^2);
freqMagnitude(1,1) = 1; % To avoid division by zero
% Create a 1/f power spectrum
powerSpectrum = 1 ./ freqMagnitude;
% Generate random phase
randomPhase = exp(1i * 2 * pi * rand(imageSize));
% Combine magnitude and phase to create the Fourier transform
fourierTransform = powerSpectrum .* randomPhase;
% Perform the inverse Fourier transform to obtain the spatial domain image
spatialDomainImage = real(ifft2(ifftshift(fourierTransform)));
% Normalize the image to the range [0, 1]
spatialDomainImage = (spatialDomainImage - min(spatialDomainImage(:))) / ...
(max(spatialDomainImage(:)) - min(spatialDomainImage(:)));
% Display the image
imshow(spatialDomainImage, []);
title('1/f Visual Noise');
Above will be the output image. This code snippet creates a 1/f noise image by first defining a frequency grid and calculating a 1/f power spectrum. A random phase is added to the spectrum, and an inverse Fourier transform is performed to convert it back to the spatial domain. The resulting image is normalized and displayed.
Hope this helps!
0 commentaires
Voir également
Catégories
En savoir plus sur Signal Processing Toolbox dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!