Hi there. I'm having some difficulty with a little project of mine. Basically, I've written some member functions to manipulate the pixel values of a black and white image. But I'm unable to use them until I figure out how to import the image.
I have saved the image in a text file like so, where 0 = a black pixel, 255 = a white pixel and the rest are values of grey:
15,88,200
172,56,111
So on and so forth. My problem is, how can I parse the data so it can be loaded into a 2D array for me to work with? I want to make use of the commas as separators, but how can I do this? Here is some of what I have so far. Inside the while loop, I want to make the assignment of the file to imgPix.
1 2 3 4 5 6 7 8 9 10 11 12 13
bool loadData(int **imgPix, string fileName) {
ifstream fin("fileName.txt");
if (!fin) {
cout << "Could not open " << fileName;
returnfalse;
}
while (!fileName.eof) {
}
}