Convert Mat type to boolean

Hi,
how to convert a value Mat (example Mat position = (image,posit)) to bool value?
here is my code lines

``````
vector<Point> posit{Point(row,col)};
if(Mat positition = getPixels(image,posit) ==  image.at<uchar>(row,col))
``````

error → could not convert position to bool?

please explain, what you want to achieve here.
what is `getPixels()` ? and why make such a complicated `if` clause ?

(already line 1 looks like total bs, as it’s `Point(x,y)` (wrong order) and even `Point(col,row)` would probably be out-of-bounds

C++ issue. you don’t know the syntax well enough yet.

look up the precedence rules for operators.

also, do not define variables inside of expressions. if that is even possible, it’s a bad idea.

The program I’m trying to write aims to replace some pixel’s values according to their coordinates. The error message —> Mat “outp” can not be converted into bool, here is the part of the program

------------------opencv code --------------------

``````...
Mat image ;
vector<Point> coor{Point(7,7)}; // --> define a vector with a given coordinates
Mat outp = getPixels(image, coor);  // --> get the pixel's value

for (int row = 0; row < image.rows; row ++) // --> loop through the image
{
for (int col = 0; col < image.cols; col ++)
{
if( outp ==  0 ) // --> if the pixel for the given coordinates equals 0 (black pixel )
{
image.at<uchar>(row,col) = 255; // --> replace the pixel with 255 instead of 0
int pixelValue = image.at<uchar>(row,col);
outputFile << pixelValue << '\t';

}
else {

int pixelValue = image.at<uchar>(row,col);
outputFile << pixelValue << '\t';
}
outputFile << endl;``````

in OpenCV, single pixels aren’t represented by Mats, but by `Vec3b` (for uint8 values).

your `getPixels` function is mysterious.

perhaps you’d have less headache if you just used python. it doesn’t get in your way like C++ does.