In MATLAB, it is easy to plot multiple graph in single figure. we use only one command to do this:
subplot(2,2,1);
imshow(img);
However, as far as I know, there is no inbuilt support to display more than one image in OpenCV. There are two major directions on solving this problem. One is to join multiple images into one Single Big image, the other is to use a third-party library to compensate the deficiency.
1. Join multiple images into one Single Big image
1.1 set the ROIs of a Single Big image and then resizing and copying the input images to the Single Big Image
Mat eigenface[3];
eigenface[0] = imread(image0,IMREAD_GRAYSCALE);
eigenface[1] = imread(image1,IMREAD_GRAYSCALE);
eigenface[2] = imread(image2,IMREAD_GRAYSCALE);
//Display multiple images in single window
Mat dst(images[0].rows,(images[0].cols+10)*3,CV_8UC1,0);
Mat roi = dst(Rect(5,0,images[0].cols,images[0].rows));
eigenface[0].copyTo(roi);
roi = dst(Rect(images[0].cols+10,0,images[0].cols,images[0].rows));
eigenface[1].copyTo(roi);
roi = dst(Rect((images[0].cols+10)*2,0,images[0].cols,images[0].rows));
eigenface[3].copyTo(roi);</span>
1.2 use inbuilt function “hconcat” and “vconcat” in OpenCV
Mat eigenface[3];
eigenface[0] = imread(image0,IMREAD_GRAYSCALE);
eigenface[1] = imread(image1,IMREAD_GRAYSCALE);
eigenface[2] = imread(image2,IMREAD_GRAYSCALE);
Mat dst;
hconcat(eigenface,3,dst);
2. Use the third-party library
I introduce two excellent third-party libraries for image load and display here
1) Emgu CV
Emgu CV is a cross platform .Net wrapper to the OpenCV image processing library. Allowing OpenCV functions to be called from .NET compatible languagesuch as C#, VB, VC++, IronPython etc.
2) CxImage
CxImage is a C++ class to load, save, display, transform BMP,JPEG, GIF, TIFF, MNG, ICO, PCX, TGA, WMF, WBMP, JBG, J2K images.
More details on how to use these two third-party libraries, please look up the reference [3, 4].
3. Reference
[1]http://answers.opencv.org/question/23048/display-many-images-in-single-window-in-opencv/
[2]http://www.codeproject.com/Questions/595865/HowplustoplusDisplayplusMultipleplusImagesplusinpl
[3]http://code.opencv.org/projects/opencv/wiki/DisplayManyImages
在OpenCV中在一个窗口显示多张图片
在MATLAB中,使用一个命令就可以在单个图表中绘制多个图形。然而,OpenCV没有内置支持在同一窗口显示多个图像。解决这个问题主要有两个方法:将多个图像合并成一个大图像,或者使用第三方库。介绍了两种优秀的第三方库——Emgu CV和CxImage,它们分别提供了对OpenCV图像处理库的.NET包装和C++加载和显示图像的功能。
1315

被折叠的 条评论
为什么被折叠?



