日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

数字图像处理实验(5):PROJECT 04-01 [Multiple Uses],Two-Dimensional Fast Fourier Transform

發布時間:2025/3/21 编程问答 16 豆豆
生活随笔 收集整理的這篇文章主要介紹了 数字图像处理实验(5):PROJECT 04-01 [Multiple Uses],Two-Dimensional Fast Fourier Transform 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

實驗要求:

Objective:
To further understand the well-known algorithm Fast Fourier Transform (FFT) and verify its effectiveness to calculate the discrete Fourier transform (DFT).
Main requirements:
Ability of programming with C, C++, or Matlab.
Instruction manual:
The purpose of this project is to develop a 2-D FFT program “package” that will be used in several other projects that follow. Your implementation must have the capabilities to:
(a) Multiply the input image by (-1)x+y to center the transform for filtering.
(b) Multiply the resulting (complex) array by a real function (in the sense that the the real coefficients multiply both the real and imaginary parts of the transforms). Recall that multiplication of two images is done on pairs of corresponding elements.
(c) Compute the inverse Fourier transform.
(d) Multiply the result by (-1)x+y and take the real part.
(e) Compute the spectrum.
Basically, this project implements Fig. 4.5. If you are using MATLAB, then your Fourier transform program will not be limited to images whose size are integer powers of 2. If you are implementing the program yourself, then the FFT routine you are using may be limited to integer powers of 2. In this case, you may need to zoom or shrink an image to the proper size by using the program you developed in Project 02-04.
An approximation: To simplify this and the following projects (with the exception of Project 04-05), you may ignore image padding (Section 4.6.3). Although your results will not be strictly correct, significant simplifications will be gained not only in image sizes, but also in the need for cropping the final result. The principles will not be affected by this approximation.

實驗要求我們編寫程序實現2維圖像的快速傅里葉變換,并運用于頻率域濾波。
簡要介紹一下頻率域濾波的步驟:

  • 給定一幅大小為M*N的輸入圖像f(x,y),計算得到填充參數P和Q。通常,取P=2M,Q=2N;
  • 添加必要數量的0,形成大小為P*Q的填充后的圖像fp(x,y);
  • 用(-1)^(x+y)乘以fp(x,y),將圖像移到其傅里葉變換的中心處;
  • 計算(3)中的圖像DFT,得到F(u,v);
  • 生成一個實的、對稱的濾波器函數H(u,v),其大小與fp(x,y)相同,為P*Q,中心在(P/2, Q/2)。用陣列相乘形成乘積G(u,v);
  • 計算(5)中結果的逆DFT,取出實部,得到gp(x,y);
  • 從gp(x,y)的左上象限提取M*N的圖像,得到最終處理結果g(x,y)。
  • 上程序:

    %% close all; clc; clear all;%% % 讀取圖像 img = imread('gray_image.jpg'); figure(1) imshow(img); title('original A');% 得到填充參數P和Q [M, N] = size(img); P = 2 * M; Q = 2 * N;img = double(img); % 添加必要數量的0 img_fp = zeros(P, Q); img_fp(1:M, 1:N) = img(1:M, 1:N);figure(2); imshow(img_fp, []); title('image B');% 用(-1)^(x+y)乘以圖像的結果 for x = 1:Pfor y = 1:Qimg_fp(x, y) = img_fp(x, y) .* (-1)^(x+y);end end% figure(3); % imshow(img_fp, []); % title('image C');% 對圖像做快速傅里葉變換 img_Fp = fft2(img_fp);% figure(4); % imshow(img_Fp, []); % title('image D');% H = ones(P, Q); % H(P/2, Q/2) = 0;% H = zeros(P, Q); % H(P/2, Q/2) = 1; % H(P/2 - 1, Q/2 - 1) = 1;r = 30; H = ones(P, Q); for x = 1:Pfor y = 1:Qd = sqrt((x-M)^2 + (y-N)^2);if d > rH(x, y) = 0;elseH(x, y) = 1;end% if x == P/2 && y == Q/2 % H(x, y) = 1; % else % H(x, y) = 1; % endend endfigure(5); imshow(H, []); title('image E');img_G = img_Fp .* H;% figure(6); % imshow(img_G, []); % title('image F');img_g = ifft2(img_G); img_g = real(img_g);for x = 1:Pfor y = 1:Qimg_g(x, y) = img_g(x, y) .* (-1)^(x+y);end end% figure(7); % imshow(img_g, []); % title('image G');img_o = img_g(1:M, 1:N);figure(8); imshow(img_o, []); title('result H');imwrite(img_o, 'result.jpg');

    實驗結果:

    上圖是原圖像;


    上圖是步驟1和2,擴展后的圖像fp(x,y);


    上圖是濾波器函數H(u,v),中心一個圓內為1,圓外都是0,表示一個低通濾波器;


    上圖是逆DFT計算得到的gp(x,y);


    上圖為最終的結果,從gp(x,y)提取出的g(x,y)圖像;
    明顯得,可以發現,低通濾波器使原圖像變得模糊了。

    《新程序員》:云原生和全面數字化實踐50位技術專家共同創作,文字、視頻、音頻交互閱讀

    總結

    以上是生活随笔為你收集整理的数字图像处理实验(5):PROJECT 04-01 [Multiple Uses],Two-Dimensional Fast Fourier Transform的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。