Reflection projection cvcalcbackproject

Source: Internet
Author: User
# Include "CV. H "# include" cxcore. H "# include" highgui. H "# include <iostream> # include" function. H "cvhistogram * histogram2 (iplimage * SRC, int hsize) // return the normalized histogram {iplimage * srch = cvcreateimage (cvgetsize (SRC), 8, 1 ); // iplimage * SRCS = cvcreateimage (cvgetsize (SRC), 8, 1); // You can split the CIDR Block (SRC, srch, null). // create histogramcvhistogram * Hist; int dims = 1; int size [] = {hsize}; float rangeh [] = {0,180}; // float ranges [] = {0,360 }; float * ranges [] = {rangeh}; hist = cvcreatehist (dims, size, cv_hist_array, ranges); // calculate histogramiplimage * image [] = {srch}; cvcalchist (image, hist); Return hist;} int Backprojection (INT argc, char ** argv) // projection: Projection {iplimage * temp = cvloadimage ("E: \ picture \ 333.jpg"); cvhistogram * hist = histogram2 (temp, 30); iplimage * src = cvloadimage ("E: \ picture \ 3.jpg "); iplimage * imageh = cvcreateimage (cvgetsize (SRC), 8, 1); iplimage * images = cvcreateimage (cvgetsize (SRC), 8, 1); iplimage * srchsv = cvcreateimage (cvgetsize (SRC ), 8, 3); cvcvtcolor (SRC, srchsv, cv_bgr2hsv); cvsplit (srchsv, imageh, null, null); // iplimage * image [] = {imageh }; // iplimage * backprojectresult = cvcreateimage (cvgetsize (SRC), 8, 1); iplimage * backprojectresult = cvcreateimage (cvgetsize (SRC), 8, 1 ); // The result type must be the same as the input image, and hist must not be normalized. Otherwise, all values are rounded to 0 cvcalcbackproject (& imageh, backprojectresult, hist ); double max = 0; double min = 0; cvminmaxloc (backprojectresult, & min, & MAX); STD: cout <"MAX:" <max <"Min: "<min <STD: Endl; cvnamedwindow (" src "); cvnamedwindow (" Temp "); cvnamedwindow (" backprojectresult "); cvshowimage (" src ", SRC); cvshowimage ("Temp", temp); cvshowimage ("backprojectresult", backprojectresult); cvwaitkey (0); Return 0 ;}


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

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.