上QQ阅读APP看书,第一时间看更新
Getting ready
In this recipe, we again use the color reduction example described in the previous recipe.
An iterator object for a cv::Mat instance can be obtained by first creating a cv::MatIterator_ object. As is the case with cv::Mat_, the underscore indicates that this is a template subclass. Indeed, since image iterators are used to access the image elements, the return type must be known at the time of compilation. The iterator is then declared as follows:
cv::MatIterator_<cv::Vec3b> it;
Alternatively, you can also use the iterator type defined inside the Mat_ template class as follows:
cv::Mat_<cv::Vec3b>::iterator it;
Now we are going to apply the iterators to the color reduction example.