现在的位置: 首页 > 综合 > 正文

Display Multiple Images in Single Window in OpenCV

2019年09月30日 ⁄ 综合 ⁄ 共 1975字 ⁄ 字号 评论关闭

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

[4]http://www.emgu.com/wiki/index.php/Main_Page

抱歉!评论已关闭.