I'm working with the OpenCv calcHist function. the question that I to this function I put a silhouette to me to detect the values within that silhouette. if my silhouette is inside the object (of a single color, orange), it only detects in the image the color of the object.
In case the silhouette catches outside the object, the function picks up more colors. the question is that being in this situation, how can I simply get the colors that correspond to the object?
I add part of the code to get an idea. Thanks.
calcHist(&firstImage, 1, channels, this->imageMasc, this->imageHist, 3, sizes, ranges, true, false);
calcBackProject(&firstImage, 1, channels, this->imageHist, this->backProjectMask, ranges, 1, true);
cv::morphologyEx(this->backProjectMask, this->backproj, cv::MORPH_OPEN, kern);
cv::morphologyEx(this->backproj, this->imageMasc, cv::MORPH_CLOSE, kern);