1
votes

I was trying to convert every channel of a RGB image, stored in Mat channel, into 3 2D matrices, each for R,G and B. This question maybe rudimentary, but could you please tell me how I can achieve this? Am using opencv2.4.3 in Linux, Cmake compiler.

I used split, but it stores the values again in a Mat. I want a simple 2D array, that can be accessed easily, instead of Mat. Could you please help me here?

1
I tried vector<int *>channel_rgb(3) split(src,channel_rgb) and tried to access channel_rgb[0],[1],[2]. I think this is not working. - Lakshmi Narayanan
I don't really see how a 2D array is easier to access than a Mat... If you don't like the .at<type> syntax why not just cast it as a Mat_ ? - Hammer
and by 2D array do you mean an array of pointers to arrays? as in double_ptr[i][j]? If that is what you are talking about by dimensions, then internally a Mat always represents data in 1D - Hammer

1 Answers

1
votes

You can use split, from the opencv docs:

The functions split splits a multi-channel array into separate single-channel arrays