Ask Your Question

Does opencv has type cell like matlab that can store several Matrices

asked 2017-02-23 21:04:13 -0500

JaneSnow gravatar image

Hi, I am working on image processing for my thesis and I need process hundreds of images at one time, so I would like to know whether I can store these image mat in one data structure, like cell in matlab, then I can get something like the following:

Cell all_images = cell(1,numofImage); for (int i = 0; i < numofImage;i++){ Mat img = imread( image(i) ) all_images(i) = img; }

Or does there exists some other ways for me to store several images at one time? By the way, I am using VS2013 with C++. Does anyone who has some idea about it? Thanks! ^0^

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted

answered 2017-02-24 01:17:17 -0500

berak gravatar image

updated 2017-02-25 01:28:27 -0500

use a std::vector for this:

std::vector<cv::String> filenames;
cv::glob("/my/images/*.png", filenames); //all png files in that folder

std::vector<cv::Mat> images(filenames.size());
for (size_t i=0; i<filenames.size(); i++) {
    images[i] = cv::imread(filenames[i]);
edit flag offensive delete link more


Thanks! It works very well!

JaneSnow gravatar imageJaneSnow ( 2017-02-24 15:59:40 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2017-02-23 21:04:13 -0500

Seen: 121 times

Last updated: Feb 25 '17