Gamasutra is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.


Gamasutra: The Art & Business of Making Gamesspacer
Sponsored Feature: Implementation of Fast Fourier Transform for Image Processing in DirectX 10
View All     RSS
October 27, 2020
arrowPress Releases
October 27, 2020
Games Press
View All     RSS







If you enjoy reading this site, you might also want to check out these UBM Tech sites:


 

Sponsored Feature: Implementation of Fast Fourier Transform for Image Processing in DirectX 10


April 16, 2009 Article Start Previous Page 3 of 3
 

Here is the shader program that computes the butterflies in the horizontal direction.

The shader looks up the butterfly texture for the indices of the two pixels to be combined and the weight. It then computes the result by performing the complex math a+wb or a-wb. To make matters simple, the sign is encoded as part of the weight and hence only the addition is performed in the shader program every time. The result is returned with the real value in the first three components and the imaginary value in the fourth component.6

To transform the image from the frequency domain to the spatial domain the exact same operations are performed but on the frequencies. Because the frequencies are not in the range to be displayed on the screen they are scaled by a factor of 1/(Width × Height) as shown.

where ScaleFactor is set by the application to 1/(Width × Height). Finally the result is displayed in the normal mode by concentrating the lowest frequencies toward the center.7 Figures 1 and 2 show a gray scale image and the resulting image after applying FFT.


Figure 1. The original image displayed in gray scale.


Figure 2. The normal mode of the image after applying the FFT.

Conclusion

This DirectX 10 application not only implements the FFT and its inverse but also serves as a framework for implementing image-processing algorithms. A CTexture class is implemented for handling 1D and 2D texture operations. The CTexture class supports various texture formats and can be easily extended to support 3D textures. Future work will focus on making the framework a plug-in architecture allowing developers to write image processing filters and plug their algorithms into the framework.

This article detailed the implementation of FFT and its inverse for transforming a 2D image from the spatial domain to the frequency domain and back. The advantage of representing an image in the frequency space is that performing some operations on the frequencies is much more efficient than doing the same in the image space. Many of the convolutions are just multiplications in the frequency domain (the computational cost in the image space is O(N2) versus O(Nlog(N)) in the Fourier space for N points). This enables efficient implementations of very large convolutions in image processing and other algorithms in many fields.

---

6 Mitchell, Jason L., Marwan Y. Ansari, and Evan Hart, "Advanced Image Processing with DirectX® 9 Pixel Shaders." Section 4 in ShaderX2: Shader Programming Tips and Tricks with DirectX 9, Wolfgang F. Engel, ed., Plano, TX: Wordware Publishing, 2003.  

7 Mitchell, Jason L., Marwan Y. Ansari, and Evan Hart, "Advanced Image Processing with DirectX® 9 Pixel Shaders." Section 4 in ShaderX2: Shader Programming Tips and Tricks with DirectX 9, Wolfgang F. Engel, ed., Plano, TX: Wordware Publishing, 2003. 


Article Start Previous Page 3 of 3

Related Jobs

Johnson County Community College
Johnson County Community College — Overland Park, Kansas, United States
[10.26.20]

Assistant Professor, Game Development
CVEDIA
CVEDIA — London, England, United Kingdom
[10.26.20]

Senior Unity Engineer - Remote - EU Time Zone
Insomniac Games
Insomniac Games — Burbank, California, United States
[10.25.20]

Lead Gameplay Programmer
Insomniac Games
Insomniac Games — Burbank, California, United States
[10.25.20]

Lead Engine Programmer





Loading Comments

loader image