Fourier transform color

Source: Internet
Author: User

Program:

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/45/D3/wKiom1PsKJ2ymWtvAAMoT6R_idE416.jpg "Title =" clipboard.png "alt =" wkiom1pskj2ymwtvaamot6r_ide416.jpg "/>

Code:

# Include "CV. H "# include" cxcore. H "# include" highgui. H "# include <iostream> int dftcolor (INT argc, char ** argv) // Discrete Fourier Transform (discrete Fourier transform, abbreviated as DFT) {iplimage * src = cvloadimage ("E: \ picture \ 4.jpg"); iplimage * SRCB = cvcreateimage (cvgetsize (SRC), 8, 1 ); iplimage * srcg = cvcreateimage (cvgetsize (SRC), 8, 1); iplimage * srcr = cvcreateimage (cvgetsize (SRC), 8, 1); iplimage * srcb32f = cvcreateimage (getcvsize (SRC ), values, 1); iplimage * srcg32f = cvcreateimage (cvgetsize (SRC), values, 1); iplimage * srcr32f = cvcreateimage (cvgetsize (SRC), ipl_depth_32f, 1 ); iplimage * dftb32f = cvcreateimage (cvgetsize (SRC), ipl_depth_32f, 1); iplimage * dftg32f = cvcreateimage (cvgetsize (SRC), ipl_depth_32f, 1 ); iplimage * dftr32f = cvcreateimage (cvgetsize (SRC), ipl_depth_32f, 1); iplimage * dftbresult32f = cvcreateimage (cvgetsize (SRC), ipl_depth_32f, 1 ); iplimage * dftgresult32f = cvcreateimage (cvgetsize (SRC), values, 1); iplimage * dftrresult32f = cvcreateimage (cvgetsize (SRC), ipl_depth_32f, 1 ); iplimage * dftb = cvcreateimage (cvgetsize (SRC), 8, 1); iplimage * dftg = cvcreateimage (cvgetsize (SRC), 8, 1); iplimage * dftr = cvcreateimage (getcvsize (SRC ), 8, 1); iplimage * src2b32f = cvcreateimage (cvgetsize (SRC), ipl_depth_32f, 1); iplimage * src2g32f = cvcreateimage (cvgetsize (SRC), Hangzhou, 1 ); iplimage * src2r32f = cvcreateimage (cvgetsize (SRC), ipl_depth_32f, 1); iplimage * src2b = cvcreateimage (cvgetsize (SRC), 8, 1 ); iplimage * src2g = cvcreateimage (cvgetsize (SRC), 8, 1); iplimage * src2r = cvcreateimage (cvgetsize (SRC), 8, 1); iplimage * src2 = cvcreateimage (getcvsize (SRC ), 8, 3); // split color *** like cvsplit (SRC, SRCB, srcg, srcr, null); // convert B, G, r-bit 32-bit floating point cvconvertscale (SRCB, srcb32f); cvconvertscale (srcg, srcg32f); cvconvertscale (srcr, srcr32f); // perform Fourier transform cvdft (srcb32f, dftb32f, values); cvdft (srcg32f, dftg32f, cv_dxt_forward); cvdft (srcr32f, dftr32f, cv_dxt_forward); // normalize the Fourier transform result to double maxval = 0; double minval = 0; cvminmaxloc (dftb32f, & minval, & maxval); double scale = 255/(maxval-minval); double shift =-minval * scale; cvconvertscale (dftb32f, dftbresult32f, scale, shift); maxval = 0; minval = 0; cvminmaxloc (dftg32f, & minval, & maxval); Scale = 255/(maxval-minval); shift =-minval * scale; cvconvertscale (dftg32f, dftgresult32f, scale, shift); maxval = 0; minval = 0; cvminmaxloc (dftr32f, & minval, & maxval); Scale = 255/(maxval-minval ); shift =-minval * scale; cvconvertscale (dftr32f, dftrresult32f, scale, shift); // convert the Fourier transform result to 8-bit cvconvertscale (dftbresult32f, dftb); cvconvertscale, dftg); cvconvertscale (cost, dftr); // Fourier inverse cvdft (frequency, src2b32f, frequency | cv_dxt_scale); cvdft (frequency, src2g32f, frequency | cv_dxt_scale); cvdft (dftr32f, convert, convert | cv_dxt_scale); // convert the Fourier inversion result to eight-bit cvconvertscale (src2b32f, src2b); cvconvertscale (src2g32f, src2g); cvconvertscale (src2r32f, src2r ); // synthesize the original cvmerge (src2b, src2g, src2r, null, src2); // display the results cvnamedwindow ("src"); cvnamedwindow ("SRCB "); cvnamedwindow ("srcg"); cvnamedwindow ("srcr"); cvnamedwindow ("dftb"); cvnamedwindow ("dftg"); cvnamedwindow ("dftr "); cvnamedwindow ("src2b"); cvnamedwindow ("src2g"); cvnamedwindow ("src2r"); cvnamedwindow ("src2"); cvshowimage ("src", Src ); cvshowimage ("SRCB", SRCB); cvshowimage ("srcg", srcg); cvshowimage ("srcr", srcr); cvshowimage ("dftb", dftb ); cvshowimage ("dftg", dftg); cvshowimage ("dftr", dftr); cvshowimage ("src2b", src2b); cvshowimage ("src2g", src2g ); cvshowimage ("src2r", src2r); cvshowimage ("src2", src2); cvwaitkey (0); Return 0 ;}


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

Related Article

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.