Ask Your Question
0

find the differences between two images pixel I want to show on the screen with imshow method How can I do

asked 2015-07-08 04:52:13 -0600

10350 gravatar image

updated 2015-07-08 07:17:05 -0600

 Mat difference(Mat frame1, Mat frame2)
{
    Mat image = frame1.clone();


    for (int rows = 0; rows < image.rows; rows++)
    {
        for (int cols = 0; cols < image.cols; cols++)
        {

            image.at<cv::Vec3b>(rows, cols)[0] = abs(frame1.at<cv::Vec3b>(rows, cols)[0] -
                frame2.at<cv::Vec3b>(rows, cols)[0]);
            image.at<cv::Vec3b>(rows, cols)[1] = abs(frame1.at<cv::Vec3b>(rows, cols)[1] -
                frame2.at<cv::Vec3b>(rows, cols)[1]);
            image.at<cv::Vec3b>(rows, cols)[2] = abs(frame1.at<cv::Vec3b>(rows, cols)[2] -
                frame2.at<cv::Vec3b>(rows, cols)[2]);
        }
    }
    return image;
}
int main()
{

    Mat src = imread(file name);
    Mat curr_frame = imread(file name);
    Mat image = src.clone();
    cout << image.rows;
    cout << image.cols;
 differenceFrame(src, curr_frame);


 system("pause");

}
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2015-07-08 07:18:45 -0600

There is already a function for that:

cv::absdiff

http://docs.opencv.org/modules/core/d...

edit flag offensive delete link more

Comments

I dont use ready function So how do I write algorithm

10350 gravatar image10350 ( 2015-07-10 06:34:58 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2015-07-08 04:52:13 -0600

Seen: 2,460 times

Last updated: Jul 08 '15