Here img is 16UC3... Comparing is wrong...Can someone help me with this [closed]

asked 2016-10-26 05:28:17 -0600

Madalasa gravatar image

updated 2016-10-26 05:52:59 -0600

Mat image(5620, 4894, CV_16UC3, Scalar(0, 0, 0));
for (int j = 0; j < Change_Detected.rows; j++)
{
    for (int l = 0; l < Change_Detected.cols; l++)
    {
        if (img.at<Vec3b>(i,j)>200)
        {
            image.at<Vec3b>(j, l)[0] = img.at<Vec3b>(j, l)[0];
            image.at<Vec3b>(j, l)[1] = img.at<Vec3b>(j, l)[1];
            image.at<Vec3b>(j, l)[2] = img.at<Vec3b>(j, l)[2];
        }
    }
}
edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by sturkmen
close date 2020-12-04 11:41:08.871027

Comments

Instead of posting multiple questions can you clearly tell us your problem?

Balaji R gravatar imageBalaji R ( 2016-10-26 05:55:31 -0600 )edit

As Berak answered in your prev question, You are accessing the pixels wrong! i.e instead of using this

 img.at<Vec3b>(i,j)

You need to use

img.at<cv::Vec3w>(i,j)
Balaji R gravatar imageBalaji R ( 2016-10-26 05:58:23 -0600 )edit

even, if you correct the type,

the next problem is, that you're trying to compare a Vec3w to a single number here:

img.at<Vec3b>(i,j)>200

what are you trying to achieve ? which channels compare to what ?

again, please don't just throw code at us without further explanation.

berak gravatar imageberak ( 2016-10-26 06:22:42 -0600 )edit

I want to compare all 3 channels with different values.. Channel 1 >50 && channel 2 > 60 && channels 3 >110 And i want to store the values in new CV_16UC3 matrix.

Madalasa gravatar imageMadalasa ( 2016-10-26 07:09:04 -0600 )edit