OpenCV image recognition from zero to proficient (one)---multi-graph display of a window

Source: Internet
Author: User

Described earlier how to bulk read the picture, so there will also be a batch of display of pictures, then in peacetime we show the picture, will find a picture a window, will come out a lot, this time will think of MATLAB we will often use subplot display multiple pictures in a window, Before http://blog.csdn.net/qq_20823641/article/details/51910066 This article also provides a method, can refer to, after further study, from simple to complex, once again think subplot (), Feeling more and more interesting, although not the best, but is the introduction of the better, many of them can be optimized, will be in the mastery of the part of the show, here is the main entry.

One, version 1

<span style= "FONT-SIZE:18PX;" >int main (void) {vector<mat> IMGs (2) imgs[0] = Imread ("Cm.png"); imgs[1] = Imread ("Cm.png"); Mat dispimg;int x, y;x = Imgs[0].cols;    y = imgs[0].rows;int Max;max = (x > Y)? X:y;int dstsize=max;dispimg.create (Size (dstsize* () +100,dstsize), cv_8uc3), int nimg = (int) imgs.size (); for (int i=0 ; i<nimg;i++) {         int m=20+i*max;    int n=20;        Mat Imgroi = dispimg (Rect (M, n, (int) x, (int) y));    Resize (Imgs[i], Imgroi, Size ((int) x, (int) y));}      Namedwindow ("Winname");      Imshow ("Winname", dispimg);      Waitkey ();      return 0;} </span>


Second, version 2

<span style= "FONT-SIZE:18PX;" >int main (void) {vector<mat> IMGs (6) imgs[0] = Imread ("Cm.png"); imgs[1] = Imread ("Cm.png"); imgs[2] = Imread (" Lina.png "); imgs[3] = Imread (" Dr.png "); Imgs[4] = Imread (" Pom.png "); imgs[5] = Imread (" Qop.png "); Imshowmany (" Dota2_hero ", IMGs); Waitkey (); return 0;} void Imshowmany (const std::string& _winname, const vector<mat>& _imgs) {int nimg = (int) _imgs.size ();  Mat dispimg;int size;int x, y;//w-maximum number of images in a row//h-maximum number of images in a column int w, h;//Scale-how Much we have to resize the imagefloat scale;int max;if (nimg <= 0) {printf ("Number of arguments too s Mall....\n "); return;} else if (Nimg >) {printf ("Number of arguments too large....\n"); return;} else if (nimg = = 1) {w = h = 1;size = 300;} else if (nimg = = 2) {w = 2; h = 1;size = 300;} else if (nimg = = 3 | | nimg = = 4) {w = 2; h = 2;size = 300;} else if (nimg = = 5 | | nimg = = 6) {w = 3; h = 2;size = 200;} else if (nimg = = 7 | | nimg = = 8) {w = 4; h = 2;size = 200;} Else{w = 4; h = 3;size = 150;} Dispimg.create (Size (+ size*w, + size*h), cv_8uc3); for (int i= 0, m=20, n=20; i<nimg; i++, m+= (20+size)) {x = _img S[i].cols;y = _imgs[i].rows;max = (x > Y)? X:y;scale = (float) ((float) max/size), if (i%w==0 && m!=20) {m = 20;n + = 20+size;} Mat Imgroi = dispimg (Rect (M, n, (int) (X/scale), (int) (Y/scale))), resize (_imgs[i], Imgroi, Size ((int) (X/scale), (int) (y/ scale)));} Namedwindow (_winname); Imshow (_winname, dispimg);} </span>


http://blog.csdn.net/yang_xian521/article/details/7915396

http://kanwoerzi.iteye.com/blog/1304073

Third, Matlab auxiliary

Matlab on a subplot () is done, refer to this finally gave the MATLAB code and pictures http://blog.csdn.net/qq_20823641/article/details/51910066

OpenCV image recognition from zero to proficient (one)---multi-graph display of a window

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.