Discrete Fourier Transform 2 is labeled instead of normalized

Source: Internet
Author: User

Core Function: cvdft

Program:

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/45/D4/wKioL1PsKuKgMhUzAADLkNsp1PQ852.jpg "Title =" clipboard.png "alt =" wkiol1pskukgmhuzaadlknsp1pq852.jpg "/>

Code:

# Include "CV. H "# include" cxcore. H "# include" highgui. H "# include <iostream> int dft2 (INT argc, char ** argv) // Discrete Fourier Transform (discrete Fourier transform, abbreviated to DFT) {iplimage * src = cvloadimage ("E: \ picture \ 4.jpg", 0); iplimage * src32f = cvcreateimage (cvgetsize (SRC), ipl_depth_32f, 1 ); iplimage * dst32f = cvcreateimage (cvgetsize (SRC), ipl_depth_32f, 1); iplimage * dst32f_inverse = cvcreateimage (cvgetsize (SRC), ipl_depth_32f, 1 ); iplimage * dftresult_32f = cvcreateimage (cvgetsize (SRC), ipl_depth_32f, 1); iplimage * dftresult = cvcreateimage (cvgetsize (SRC), 8, 1 ); iplimage * src2 = cvcreateimage (cvgetsize (SRC), 8, 1); cvconvertscale (SRC, src32f); cvdft (src32f, dst32f, cv_dxt_forward); cvdft (dst32f, direction, cv_dxt_inverse | cv_dxt_scale); // cvconvertscale (dst32f_inverse, src2) is not normalized with cv_dxt_scale; // The Fourier transformation result is normalized to display the result double maxval = 0; double minval = 0; cvminmaxloc (dst32f, & minval, & maxval); double scale = 255/(maxval-minval); double shift =-minval * scale; cvconvertscale (dst32f, dftresult_32f, scale, shift); // convert the normalized welfare leaf transformation result to eight bits to display cvconvertscale (dftresult_32f, dftresult); cvminmaxloc (dftresult, & minval, & maxval ); STD: cout <"dftresult MAX:" <maxval <"dftresult MAX:" <minval <STD: Endl; cvnamedwindow ("src "); cvnamedwindow ("src2"); cvnamedwindow ("dftresult"); cvshowimage ("src", Src); cvshowimage ("src2", src2); cvshowimage ("dftresult ", dftresult); cvwaitkey (0); cvdestroywindow ("src"); cvdestroywindow ("src2"); cvdestroywindow ("dftresult"); cvreleaseimage (& SRC ); cvreleaseimage (& src2); cvreleaseimage (& dftresult); Return 0 ;}


This article is from the "flyclc" blog, please be sure to keep this source http://flyclc.blog.51cto.com/1385758/1539814

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.