I have a .txt file that contains information in the following pattern :

The data is separated in the form of

255,205,0 102,235,39 206,89,165 ....... (that is, 3 uint8 integers separated by commas, and the groups of 3 separated by whitespaces). There are a total of 30*60 = 1800 triplets of numbers separated by commas and the triplets are separated by spaces.

Basically, these are pixel intensities of the 3 channels in an RGB image. I need to store them in a 2 dimensional array such that the first element of each triplet goes into the 1st column, the second element into the 2nd column and the 3rd element into the 3rd column. Effectively, at the end of this operation, I should have a 2 dimensional matrix of 1800x3 size.

Please help me with this. I have attached a sample text file. Thanks in advance.

More Kumar Abhishek's questions See All
Similar questions and discussions