Ask Your Question

Revision history [back]

Hi @vitruvius

Since the color of Coin & the background are quite distinct,the correct solution is to simply switch to different color space(i.e HSV color space )!

Mat mSource_Bgr,mSource_Hsv,mMask;
mSource_Bgr= imread(FileName_S,1);
imshow("Source Image",mSource_Bgr);
cvtColor(mSource_Bgr,mSource_Hsv,COLOR_BGR2HSV);
inRange(mSource_Hsv,Scalar(0,55,0),Scalar(30,255,255),mMask);

imshow("Mask Image",mMask);

image description

Hi @vitruvius

Since the color of Coin & the background are quite distinct,the correct solution is to simply switch to different color space(i.e HSV color space )!

Mat mSource_Bgr,mSource_Hsv,mMask;
mSource_Bgr= imread(FileName_S,1);
imshow("Source Image",mSource_Bgr);
cvtColor(mSource_Bgr,mSource_Hsv,COLOR_BGR2HSV);
inRange(mSource_Hsv,Scalar(0,55,0),Scalar(30,255,255),mMask);

imshow("Mask Image",mMask);

image descriptionimage description