My function below should change the color values of the original picture and then once the process is done it should create another picture with the changed colors.
void change(const cv::Mat &first_image, cv::Mat &new_image, const std::vector<std::vector<int> > &colors)
{
for (int i = 0; i < first_image.cols; i++) {
for (int j = 0; j < first_image.rows; j++) {
int blue = first_image.at<cv::Vec3b>(i,j)[0];
new_image.at<cv::Vec3b>(i,j)[2]= colors [2][blue];
int green = first_image.at<cv::Vec3b>(i,j)[1];
new_image.at<cv::Vec3b>(i,j)[1]= colors [1][green];
int red = first_image.at<cv::Vec3b>(i,j)[2];
new_image.at<cv::Vec3b>(i,j)[0]= colors [0][red];
}
}
}
when I use the command make and run the whole code I get a segmentation fault. I use this command to run the code
../../build/mv/task/mvtask1d pic.json
Could someone tell me what I could be doing wrong?
Thank you in advance