void solveAndPaintOutput(int x0, int y0, int n, int mn, Vector rgbVector[3], const SparseMatrix& matrix, Vector solutionVectors[3], IImage& outputImage) { for (int color = 0; color < 3; color++) { cout << "Solving..."<<endl; // solve equations set for current color if (solveLinear(matrix, solutionVectors[color], rgbVector[color]) == 0) { cout << "FAIL main(): matrix.solve() failed with color: "<<color<<endl; return; } else { cout << "Done solving color "<<color<<endl; } // fill output image for (int pixel = 0; pixel < mn; pixel++) { int y = pixel / n; int x = pixel - n * y; int updateVal = (int)solutionVectors[color][pixel]; if (updateVal > 255) { updateVal = 255; } else if (updateVal < 0) { updateVal = 0; } int updatedRGBVal = getUpdatedRGBValue(outputImage.getRGB(x + x0, y + y0), updateVal, color); outputImage.setRGB(x + x0, y + y0, updatedRGBVal); } cout<<"Done applying color "<<color<<" to output"<<endl; } }