Ask Your Question
0

How to read an image from an array character ?

asked 2016-06-15 11:36:26 -0600

damiya14 gravatar image

i have and array containing file name (number) without the extension (.jpg)

as an example - [ 1, 0, 14; 3. 0, 10; 4. 2, 15] in this first column represent the file name.

how can i load first image and do the operation and load the next image and do the operation again.

edit retag flag offensive close merge delete

Comments

1

Is it an exercise ?

LBerger gravatar imageLBerger ( 2016-06-15 14:37:14 -0600 )edit

how on earth would [1,3,4] represent a file name ?

"how can i load first image and do the operation and load the next image and do the operation again."

what ?

berak gravatar imageberak ( 2016-06-16 04:26:04 -0600 )edit
1

files are named like 1.jpg ,3.jpg and 4.jpg

damiya14 gravatar imagedamiya14 ( 2016-06-16 04:33:39 -0600 )edit

^^ ah, ok, makes sense now.

berak gravatar imageberak ( 2016-06-16 04:49:13 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2016-06-16 04:42:55 -0600

berak gravatar image

updated 2016-06-16 05:01:44 -0600

if i understood you right, you have a 2d Mat, where the 1st column contains "file numbers"

[ 1, 0, 14;
  3, 0, 10;
  4, 2, 15]

// extract column:
Mat col = m.col(0);
// read files:
vector<Mat> images;
for (int i=0; i<col.rows; i++)
{
    // assuming CV_8U for m.type() here !!
    String filename = format("%d.jpg", col.at<uchar>(i));
    Mat im = imread(filename);
    if (im.empty()) .... BARK !
    images.push_back(im);
}
edit flag offensive delete link more

Comments

1

thanks mate

damiya14 gravatar imagedamiya14 ( 2016-06-16 09:24:26 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-06-15 11:36:26 -0600

Seen: 376 times

Last updated: Jun 16 '16