Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is cv::setTo function

Tags:

c++

opencv

I have a code written using OpenCV in C++, and this code uses a function setTo. Basically, it is used as:

cv::Mat xx; //prefedined and has some values
cv::Mat yy; // initially empty

yy.setTo(0,xx);

So can you explain what does this setTo means here? Does is put all zero values in yy, or it puts 1 where xx is non-zero and 0 where xx is zero too?

like image 488
user1132254 Avatar asked Jan 23 '12 12:01

user1132254


1 Answers

yy.setTo(0) will set all the pixels to 0.

yy.setTo(0, xx) will set all the pixels who have a corresponding pixel with a non-zero value in the xx Mat to 0.

Example:

yy =
2 2 2
2 2 2
2 2 2

xx =
0 0 0
0 1 0
0 0 0

yy.setTo(0, xx) =>

yy = 
2 2 2
2 0 2
2 2 2
like image 167
Boaz Avatar answered Sep 16 '22 15:09

Boaz