these question is a follow to this one, i have an image which i want to remove logo from it, i have eroded the image until all the small text are gone away and only the logo is the remaining , now i have two images , the original image and the one with only the logo , now when i attempt to subtract the two images in order to form a third one contains only the text,a weird thing happens, the logo doesn't removed but it's outlined
code:
cv::Mat final;
cv::Mat greyMat = [self.imageView.image CVGrayscaleMat];
cv::Mat bwMat,erodedMat;
cv::threshold(greyMat, bwMat, 128, 255, CV_THRESH_BINARY);
cv::bitwise_not(bwMat, bwMat);
cv::Mat element = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(20, 12));
cv::erode(bwMat, erodedMat, element);
cv::dilate(bwMat, erodedMat, bwMat);//I used this to restore all the missed components of the logo during erosion,bwMat in the last argument acts as a mask, i didn't sure of this
std::vector<cv::Point>points;
cv::Mat_<uchar>::iterator it=bwMat.begin<uchar>();
cv::Mat_<uchar>::iterator end=bwMat.end<uchar>();
for (; it!=end; ++it)
if (*it)
points.push_back(it.pos());
final=bwMat-erodedMat;