FFT of a Block processed image.

1 visualizzazione (ultimi 30 giorni)
Rai-Mond Davidson
Rai-Mond Davidson il 12 Apr 2021
Commentato: omar Alharbi il 12 Mag 2021
Hello, I am trying to do FFT on each block of a block processed image. All I have now is the block processed image that works fine but I would like to apply FFT to each block. Can anyone help?
CODE:
Image = imread("Kobe.jpg");
[Image_Height,Image_Width,Number_Of_Colour_Channels] = size(Image);
Block_Size = 50;
Number_Of_Blocks_Vertically = floor(Image_Height/Block_Size);
Number_Of_Blocks_Horizontally = floor(Image_Width/Block_Size);
Image_Blocks = struct('Blocks',[]);
Index = 1;
for Row = 1: +Block_Size: Number_Of_Blocks_Vertically*Block_Size
for Column = 1: +Block_Size: Number_Of_Blocks_Horizontally*Block_Size
Row_End = Row + Block_Size - 1;
Column_End = Column + Block_Size - 1;
if Row_End > Image_Height
Row_End = Image_Height;
end
if Column_End > Image_Width
Column_End = Image_Width;
end
Temporary_Tile = Image(Row:Row_End,Column:Column_End,:);
%Storing blocks/tiles in structure for later use%
Image_Blocks(Index).Blocks = Temporary_Tile;
subplot(Number_Of_Blocks_Vertically,Number_Of_Blocks_Horizontally,Index); imshow(Temporary_Tile);
Index = Index + 1;
end
end

Risposte (2)

Matt J
Matt J il 12 Apr 2021
Modificato: Matt J il 12 Apr 2021
Using mat2tiles ( Download )
Image = imread("Kobe.jpg");
ImageTiles=mat2tiles(Image,[50,50]);
ImageTilesFFT = cellfun(@fft2,ImageTiles,'uni',0);
  6 Commenti
Rai-Mond Davidson
Rai-Mond Davidson il 12 Apr 2021
place this code:
Image = imread("Kobe.jpg");
ImageTiles=mat2tiles(Image,[50,50]);
ImageTilesFFT = cellfun(@fft2,ImageTiles,'uni',0);
After the function code or before?
Matt J
Matt J il 12 Apr 2021
Modificato: Matt J il 12 Apr 2021
That's the whole thing! You can get rid of everything you originally had, except of course for
Image = imread("Kobe.jpg");

Accedi per commentare.


Image Analyst
Image Analyst il 12 Apr 2021
You can just do
ft = fft(Temporary_Tile);
Then do with ft whatever you want to.
  1 Commento
omar Alharbi
omar Alharbi il 12 Mag 2021
Hello Image Analyst,
If I would like to compute and plot the 2D frequency spectrum for multiple images, can I do that for each individual image and the avrege them? here is the code:
min=zeros;
min_1D=zeros;
for K = 1 :1500:75000
this_file = strcat('folder\frame',num2str(K),'.tif');
im_input = imread(this_file);
im_input = rgb2gray(im_input);
zfmin=fft2(im_input);
shiftmin=fftshift(zfmin);
min_2D=abs(shiftmin);
z_min=log10(min_2D);
min=min+z_min;
end
PSD_2D= (min)/ 50;
figure,
imagesc(PSD_2D)
colormap gray
1- is this a right way compute the spectrum?
2- If I would like to remove the DC component, I tried
zfmin= fft2(im_input-mean2((im_input))... do you recommend other way?
Thanks

Accedi per commentare.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by