
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is Image Array in C++? Explained with Example
An array is a convenient method to store and retrieve the collection of data. In OpenCV, we can use this concept to load multiple images in an image array and show them using the array's index number.
The following program loads multiple images in a matrix array and shows the array's images called by the index number.
Example
#include<iostream> #include<opencv2/highgui/highgui.hpp> using namespace cv; using namespace std; int main(int argc,const char** argv) { Mat myImage_array[3];//declaring a matrix named myImage// namedWindow("PhotoFrame1");//declaring the window to show the image// namedWindow("PhotoFrame2");//declaring the window to show the image// namedWindow("PhotoFrame3");//declaring the window to show the image// myImage_array[0]= imread("cat.jpg");//loading the image named cat in the matrix// myImage_array[1] = imread("cat.jpg");//loading the image named cat in the matrix// myImage_array[2] = imread("cat.jpg");//loading the image named cat in the matrix// imshow("PhotoFrame1", myImage_array[0]);//display the image which is stored in the 'img' in the "MyWindow" window// imshow("PhotoFrame2", myImage_array[1]);//display the image which is stored in the 'img' in the "MyWindow" window// imshow("PhotoFrame3", myImage_array[2]);//display the image which is stored in the 'img' in the "MyWindow" window// waitKey(0);//wait till user press any key return 0; }
Output
Advertisements