Skip to content

Instantly share code, notes, and snippets.

@OrganicIrradiation
Created March 23, 2015 10:16
Show Gist options
  • Save OrganicIrradiation/bcba07a2c11c1a93cf54 to your computer and use it in GitHub Desktop.
Save OrganicIrradiation/bcba07a2c11c1a93cf54 to your computer and use it in GitHub Desktop.
3D MATLAB noise – effect of changing Gaussian convolution kernel size
i = 64;
for k = 1:2:31
tic;
noise{i,k} = noise3Dwrap(i,k);
imwrite(reshape(noise{i,k},[i i 1 i]),...
['noise3Dwrap_s' num2str(i) 'k' num2str(k) '.gif'],...
'LoopCount',Inf,'DelayTime',0.10);
timeToProcess{i,k} = toc;
save('noise3Dwrap64_k1_31.mat')
end
i = 64;
for k = 1:2:31
fftObj = vision.FFT;
% Open the GIF for the current image
theGIF = imread(['noise3Dwrap_s' num2str(i) 'k' num2str(k) '.gif'],'frames','all');
for j = 1:size(theGIF,4)
% Calculate 2D FFT
% See: http://www.mathworks.com/help/vision/ref/vision.fftclass.html
I = im2single(theGIF(:,:,:,j));
J = step(fftObj, I);
J_shifted = fftshift(J);
% Display false-color image of 2D FFT
figure(1);
imshow(log(max(abs(J_shifted), 1e-6)),[]), colormap(jet(256));
% Capture screen shot for GIF
% See: http://www.mathworks.com/support/solutions/en/data/1-48KECO/index.html
frame = getframe;
im = frame2im(frame);
[imind,cm] = rgb2ind(im,256);
% Write frame to file
if j == 1;
imwrite(imind,cm,['noise3Dwrap2DFFT_s' num2str(i) 'k' num2str(k) '.gif'],...
'gif', 'Loopcount',inf,'DelayTime',0.10);
else
imwrite(imind,cm,['noise3Dwrap2DFFT_s' num2str(i) 'k' num2str(k) '.gif'],...
'WriteMode','append','DelayTime',0.10);
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment