Opencv-the block distance from L1 to L2 is originally here! CvNorm ()

Source: Internet
Author: User

 

It takes N long to calculate the distance. Oreilly's <Learning OpenCV> is still king.

 

# Include "stdafx. h "<br/> # include <cv. h> <br/> # include <pighgui. h> </p> <p> float Array1 [] = {1,-}; <br/> float Array2 [] = {, 2 }; <br/> // uchar MaskArray [] = {1, 1, 0}; </p> <p> int main () <br/>{ <br/> CvMat * Mat1 = cvCreateMat (1, 3, CV_32FC1); <br/> CvMat * Mat2 = cvCreateMat (1, 3, CV_32FC1 ); <br/> cvSetData (Mat1, Array1, Mat1-> step); <br/> cvSetData (Mat2, Array2, Mat2-> step ); </p> <p> printf ("1-norm is: %. 1f/n ", cvNorm (Mat2, Mat1, CV_L1); <br/> // printf (" 1-norm + mask is: %. 1f/n ", cvNorm (Mat2, NULL, CV_L1, Mat1); <br/> printf (" 2-norm is: %. 3e/n ", cvNorm (Mat2, Mat1, CV_L2); <br/> // printf (" 2-norm + mask is: %. 3e/n ", cvNorm (Mat2, NULL, CV_L2, Mat1); <br/> printf (" Infininte norm is: %. 1f/n ", cvNorm (Mat2, Mat1, CV_C); <br/> // printf (" Infininte norm + mask is: %. 1f/n ", cvNorm (Mat2, NULL, CV_C, Mat1); </p> <p> printf (" Relative 1-norm distance is: %. 1f/n ", cvNorm (Mat2, Mat1, CV_RELATIVE_L1, 0); <br/> printf (" Relative 2-norm distance is: %. 3f/n ", cvNorm (Mat1, Mat2, CV_RELATIVE_L2); <br/> printf (" Relative infininte norm distance is: %. 1f/n ", cvNorm (Mat1, Mat2, CV_RELATIVE_C); </p> <p> system (" pause "); <br/> cvReleaseMat (& Mat1 ); <br/> cvReleaseMat (& Mat2); <br/>}< br/>

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.