OpenCV中的Image Watch,VS2013像matlab一样方便查看图像Mat像素值等

一直以来,很多时候都是用Matlab来进行图像处理和算法研究,主要是觉得其可以方便的查看图像、像素点等等(本人是菜鸟,如果是高手可以快速用C语言实现的请指导),所以一直以来都是matlab来写算法,不过这样写有个大麻烦就是转化成工程代码还得再次写C/C++,离工程应用总觉得差那么一步。最近刚好看到这个VS2012以后的插件Image Watch可以代替部分matlab里面显示图像信息很方便的功能,很受用。

这位仁兄是发现这个功能比较早的:http://www.cnblogs.com/liu-jun/p/3161654.html

基本功能都介绍的很详细,几个链接如下:插件的下载链接:https://visualstudiogallery.msdn.microsoft.com/e682d542-7ef3-402c-b857-bbfba714f78d

OpenCV对插件的介绍:http://opencv.org/image-debugger-plug-in-for-visual-studio.html

详细的介绍文档:http://docs.opencv.org/2.4/doc/tutorials/introduction/windows_visual_studio_image_watch/windows_visual_studio_image_watch.html#windows-visual-studio-image-watch

研发团队对该插件的详细介绍:http://research.microsoft.com/en-us/um/redmond/groups/ivm/imagewatchhelp/imagewatchhelp.htm#_Toc351981444

下面以官网上的代码进行简介:


  1. // Test application for the Visual Studio Image Watch Debugger extension  
  2.   
  3. #include <iostream>                        // std::cout  
  4. #include <opencv2/core/core.hpp>           // cv::Mat  
  5. #include <opencv2/highgui/highgui.hpp>     // cv::imread()  
  6. #include <opencv2/imgproc/imgproc.hpp>     // cv::Canny()  
  7.   
  8. using namespace std;  
  9. using namespace cv;  
  10.   
  11. void help()  
  12. {  
  13.     cout  
  14.         << ”—————————————————-“ << endl  
  15.         << ”This is a test program for the Image Watch Debugger ” << endl  
  16.         << ”plug-in for Visual Studio. The program loads an     ” << endl  
  17.         << ”image from a file and runs the Canny edge detector. ” << endl  
  18.         << ”No output is displayed or written to disk.”  
  19.         << endl  
  20.         << ”Usage:”                                               << endl  
  21.         << ”image-watch-demo inputimage”                          << endl  
  22.         << ”—————————————————-“ << endl  
  23.         << endl;  
  24. }  
  25.   
  26. int main(int argc, char *argv[])  
  27. {  
  28.     help();  
  29.   
  30.     if (argc != 2)  
  31.     {  
  32.         cout << ”Wrong number of parameters” << endl;  
  33.         return -1;  
  34.     }  
  35.   
  36.     cout << ”Loading input image: ” << argv[1] << endl;  
  37.     Mat input;  
  38.     input = imread(argv[1], CV_LOAD_IMAGE_COLOR);  
  39.   
  40.     cout << ”Detecting edges in input image” << endl;  
  41.     Mat edges;  
  42.     Canny(input, edges, 10, 100);  
  43.   
  44.     return 0;  
  45. }  
// Test application for the Visual Studio Image Watch Debugger extension





#include <iostream> // std::cout #include <opencv2/core/core.hpp> // cv::Mat #include <opencv2/highgui/highgui.hpp> // cv::imread() #include <opencv2/imgproc/imgproc.hpp> // cv::Canny() using namespace std; using namespace cv; void help() { cout << "----------------------------------------------------" << endl << "This is a test program for the Image Watch Debugger " << endl << "plug-in for Visual Studio. The program loads an " << endl << "image from a file and runs the Canny edge detector. " << endl << "No output is displayed or written to disk." << endl << "Usage:" << endl << "image-watch-demo inputimage" << endl << "----------------------------------------------------" << endl << endl; } int main(int argc, char *argv[]) { help(); if (argc != 2) { cout << "Wrong number of parameters" << endl; return -1; } cout << "Loading input image: " << argv[1] << endl; Mat input; input = imread(argv[1], CV_LOAD_IMAGE_COLOR); cout << "Detecting edges in input image" << endl; Mat edges; Canny(input, edges, 10, 100); return 0; } 该代码是一个简单的图片读入,然后进行边缘处理的代码,根据该代码,进行图片显示的步骤如下:

1.采用debug模式进行编译,设置一个断点

../../../../_images/breakpoint.png

2.查看debug模式下哪些变量是可见的:Debug ‣ Windows ‣ Locals

3. 查看debug模式下哪些变量是可见的

../../../../_images/vs_locals.png

4.在运行debug模式下,运行到断点处的时候,可以打开image watch插件进行查看:View ‣ Other Windows ‣ Image Watch

../../../../_images/toolwindow.jpg

这个时候可以清楚的在Image watch窗口里面看到所有的图像Mat,然后点击就可以显示每个图像了,在图像显示区域G进行显示。这个插件做的比较好的就是,可以实时显示鼠标的坐标(H区域)和像素值,还可以通过鼠标滚轮进行放大缩小等,详细的可以参考链接介绍。


至此,基本的类似Matlab显示图像和查看像素值等功能已经完成,除了这个之后,该插件还有一些很厉害的功能,在图片区域点击鼠标右键可以看到这些功能


主要是Link views这个功能比较强大,它可以在原始图像上选择一块区域,然后设置好,再点击后续的mat,就可以看到其他图像在设置区域内的变化,这个很强大!可以实时查看局部区域图像处理的结果。

其他的功能还有缩小和放大等,基本和matlab差不多,可以放大到像素级的,然后通过Link views查看局部的像素值随着算法运行而改变的情况等等。

../../../../_images/edges_zoom.png

差不多这些处理步骤在基本的图像算法里面就够用了,基本可以替代matlab的一些图像显示的功能了,当然还有更多的功能,请参见http://research.microsoft.com/en-us/um/redmond/groups/ivm/imagewatchhelp/imagewatchhelp.htm


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值