"Exercise 6.5"

Source: Internet
Author: User
Tags scalar

Outline
Topic Requirements
Program code
Result picture
Homilies Miao DAO

Title Requirements:

Excellent code reference:

1#include <iostream>2#include <cv.h>3#include 4#include <cxcore.h>5 6 using namespacestd;7 ConstCvsize size = Cvsize ( $, $);8 Const intAperture[] = {3,5,9, One, -, -};9 intMain ()Ten { OneIplimage *src = cvcreateimage (Size,8,1); A Cvzero (SRC); - cvline (src -         //, Cvpoint (0,size.height-1) the         //, Cvpoint (size.width-1, 0) -, Cvpoint (0,0) -, Cvpoint (Size.width-1, Size.Height-1) -, Cv_rgb (255,255,255) +,3 -         ); +Cvshowimage ("src", SRC); A      atIplimage *deriv_x = Cvcreateimage (size,ipl_depth_32f,1); -Iplimage *deriv_y = Cvcreateimage (size,ipl_depth_32f,1); -Iplimage *magnitude = Cvcreateimage (size,ipl_depth_32f,1); -Iplimage *angle = Cvcreateimage (size,ipl_depth_32f,1); -Iplimage *mask = Cvcreateimage (size,ipl_depth_8u,1); -      for(intI=0;i<sizeof(Aperture)/sizeof(aperture[0]);++i) { inCvsobel (src,deriv_x,1,0, Aperture[i]); -Cvsobel (Src,deriv_y,0,1, Aperture[i]); to  +Cvcarttopolar (Deriv_x,deriv_y,magnitude,angle,1); -  theCvsave ("X.xml", deriv_x); *Cvsave ("Y.xml", deriv_y); $Cvsave ("Magnitude.xml", magnitude);Panax NotoginsengCvsave ("Angle.xml", angle); -  the         DoubleMax_mag, Min_mag, Max_angle, Min_angle; +Cvminmaxloc (magnitude,&min_mag,&max_mag); ACvminmaxloc (angle,&min_angle,&max_angle); thecout<<"Magnitude:max ="<<max_mag<<"min ="<<min_mag<<Endl; +cout<<"Angle:max ="<<max_angle<<"min ="<<min_angle<<Endl; -          $Cvcmps (magnitude,max_mag*3/4, MASK,CV_CMP_GT); $Cvshowimage ("Mask", mask); -  -Cvscalar scalar =Cvavg (angle,mask); thecout<<"aperture ="<<aperture[i]<<", line angle ="<<scalar.val[0]<<Endl; - Cvwaitkey ();Wuyi     } theCvreleaseimage (&src); -Cvreleaseimage (&magnitude); WuCvreleaseimage (&angle); -Cvreleaseimage (&mask); About cvdestroyallwindows (); $  -}
View Code

from: Learning OpenCV Sixth Exercise 5, using the X, Y hierarchy to find the angle of a unique line within an image

Program code:

Result Picture:

Homilies Miao DAO:

"Exercise 6.5"

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.