Ask Your Question
1

How to create a vector of images in opencv ?

asked 2015-02-28 14:42:49 -0600

Diego Moreira gravatar image

updated 2015-09-30 10:47:24 -0600

i need store various images in a vector using opencv ? How to make this ?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
3

answered 2015-02-28 14:45:27 -0600

updated 2015-02-28 15:18:16 -0600

I think this should be straight straithforward supposing you know how to read images.

Mat image1 = imread("location_image1"); 
Mat image2 = imread("location_image2"); 
vector<Mat> various_images;
various_images.push_back(image1);
various_images.push_back(image2);

With this code you can create loops of your desire!

UPDATE:

And to access elements of your matrix, it all kind of depends what type of matrix you are using but in the case of a matrix of type CV_8UC1 you can use the command

int currentElement = image.at<uchar>(row,col);

If you have a multi channel image than first use the split function

UPDATE 2:

Access of a vector is done by

Mat retrieve_element = various_images[index];

where index is a number between 0 and amountElements-1

edit flag offensive delete link more

Comments

1

Steven how to access the elements of a vector ? Do you know ?

Diego Moreira gravatar imageDiego Moreira ( 2015-02-28 15:06:43 -0600 )edit

Added above! But this can all be found in the documentation of OpenCV ...

StevenPuttemans gravatar imageStevenPuttemans ( 2015-02-28 15:10:25 -0600 )edit
1

Sorry! I answer wrong. I need access the image of a vector. How to access ?

Diego Moreira gravatar imageDiego Moreira ( 2015-02-28 15:12:46 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2015-02-28 14:42:49 -0600

Seen: 9,914 times

Last updated: Feb 28 '15