In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "how to display multiple images in the same window by OpenCV". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how OpenCV can display multiple images in the same window.
The parameters that you need to provide are as follows:
1. Vector of Mat of image sequence
2. Subplot settings similar to matlab
3. The maximum size displayed in a single image. Default is cvSize (400,280).
Due to time constraints, this version of the code can only batch display images of the same size.
The code is as follows:
/ * Author: Xin Yang* Date: 2014 Address 03 * Address: Shenzhen Univ School of medicine.* Email: xinyang@szu.edu.cn* function: Show multiple images in one window****/#include "opencv2/opencv.hpp" using namespace cv Using namespace std;void MultiImage_OneWin (const std::string& MultiShow_WinName, const vector& SrcImg_V, CvSize SubPlot, CvSize ImgMax_Size = cvSize (400,280); int main (void) {vector imgs (4); imgs [0] = imread ("F:\\ SA.jpg"); imgs [1] = imread ("F:\\ SA.jpg"); imgs [2] = imread ("F:\\ SA.jpg") Imgs [3] = imread ("F:\\ SA.jpg"); MultiImage_OneWin ("Multiple Images", imgs, cvSize (2,2), cvSize (400280)); return 0;}
[modification Note 20141119] Note 39 lines in the following code, type of Disp_Img creation, CV_8UC3 (8-bit 3-channel, see http://blog.csdn.net/yang_xian521/article/details/7107786 for details). Readers can modify it according to their own image data types, or use parameters to pass in (CV_8UC3 is essentially an integer macro).
Void MultiImage_OneWin (const std::string& MultiShow_WinName, const vector& SrcImg_V, CvSize SubPlot, CvSize ImgMax_Size) {/ / Reference: http://blog.csdn.net/yangyangyang20092010/article/details/21740373 / / * Usage * / vector imgs (4); / / imgs [0] = imread ("F:\\ SA2014.jpg") / / imgs [1] = imread ("F:\\ SA2014.jpg"); / / imgs [2] = imread ("F:\\ SA2014.jpg"); / / imgs [3] = imread ("F:\\ SA2014.jpg"); / / MultiImage_OneWin ("T", imgs, cvSize (2,2), cvSize (400,280)); / / Window's image Mat Disp_Img / / Width of source image CvSize Img_OrigSize = cvSize (SrcImg_V [0] .cols, SrcImg_V [0] .rows); / / * Set the width for displayed image * / Width vs height ratio of source image float WH_Ratio_Orig = Img_OrigSize.width/ (float) Img_OrigSize.height CvSize ImgDisp_Size = cvSize (100,100); if (Img_OrigSize.width > ImgMax_Size.width) ImgDisp_Size = cvSize (ImgMax_Size.width, (int) ImgMax_Size.width/WH_Ratio_Orig); else if (Img_OrigSize.height > ImgMax_Size.height) ImgDisp_Size = cvSize ((int) ImgMax_Size.height*WH_Ratio_Orig, ImgMax_Size.height) Else ImgDisp_Size = cvSize (Img_OrigSize.width, Img_OrigSize.height); / / * Check Image numbers with Subplot layout * / / int Img_Num = (int) SrcImg_V.size () If (Img_Num > SubPlot.width * SubPlot.height) {cout
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.