我是靠谱客的博主 斯文网络,这篇文章主要介绍Mat imread 与 IplImage cvLoadImage区别,现在分享给大家,希望可以做个参考。

1- Mat and Imread
2- IplImage and CvLoadImage    
Which one is better to use?

A : They are the two different interfaces (Mat/imread for C++ and Ipl... and Cv.. for C interface). The C++ interface is nicer, safer and easier to use. It automatically handles memory for you, and allows you to write less code for the same task. The OpenCV guys advocate for the usage of C++, unless some very specific project requirements force you to C.

Example (C++)

cv::Mat image = imread("path/to/myimage.jpg") if(image.empty()) return; cv::imshow("Image", image); cv::Mat bw = image > 128; // threshold image cv::Mat crop = image(cv::Rect(0, 0, 100, 100)); // a 100px x 100px crop crop= 0; // set image to 0 cv::waitKey();

Note that if not stated otherwise, all matrix assignments reference the same data. In the example above, the crop matrix points to image, and setting it to zero will set that specific part of the image to 0.

To create a new copy of data, use Mat::copyTo, or Mat::clone();

And the C interface

IplImage* pImg = CvLoadImage("path/to/myimage.jpg"); if(pImg == NULL) return; // ... big bloat to do the same operations with IplImage CvShowImage("Image", pImg); cvWaitKey(); CvReleaseImage(&pImg); // Do not forget to release memory.

另:来源2
1.imread是C++接口,cvloadimage是c接口。
2.imread的定义在highgui.hpp中,cvloadimage的定义在highgui-c.h中,而highgui.hpp和highgui-c.h都包含在highgui.h中,所以我们在写程序是只要包含了highgui.h,那么我们就可以用两个接口。

最后

以上就是斯文网络最近收集整理的关于Mat imread 与 IplImage cvLoadImage区别的全部内容,更多相关Mat内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(47)

评论列表共有 0 条评论

立即
投稿
返回
顶部