Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Same output threshold image

I use three filter as below, each one if I run individual work well(three output image 'imgThresholded' is difference), but if I use continuously all, the output image 'imgThresholded' is the last one.

void filterBlack(){ inRange(imgHSV, Scalar(Hblack.iLVal / 2, Sblack.iLVal, Vblack.iLVal2.55), Scalar(Hblack.iHVal / 2, Sblack.iHVal2.55, Vblack.iHVal2.55), imgThresholded); erode(imgThresholded, imgThresholded, getStructuringElement(MORPH_ELLIPSE, Size(3, 3))); dilate(imgThresholded, imgThresholded, getStructuringElement(MORPH_ELLIPSE, Size(3, 3))); //morphological closing (fill small holes in the foreground) dilate(imgThresholded, imgThresholded, getStructuringElement(MORPH_ELLIPSE, Size(3, 3))); erode(imgThresholded, imgThresholded, getStructuringElement(MORPH_ELLIPSE, Size(3, 3))); imshow(thhdWindow, imgThresholded); } void filterBlue(){ inRange(imgHSV, Scalar(Hblue.iLVal / 2, Sblue.iLVal, Vblue.iLVal2.55), Scalar(Hblue.iHVal / 2, Sblue.iHVal2.55, Vblue.iHVal2.55), imgThresholded); erode(imgThresholded, imgThresholded, getStructuringElement(MORPH_ELLIPSE, Size(3, 3))); dilate(imgThresholded, imgThresholded, getStructuringElement(MORPH_ELLIPSE, Size(3, 3))); //morphological closing (fill small holes in the foreground) dilate(imgThresholded, imgThresholded, getStructuringElement(MORPH_ELLIPSE, Size(3, 3))); erode(imgThresholded, imgThresholded, getStructuringElement(MORPH_ELLIPSE, Size(3, 3))); imshow(thhdWindow, imgThresholded); } void filterRed(){ inRange(imgHSV, Scalar(Hred.iLVal / 2, Sred.iLVal, Vred.iLVal2.55), Scalar(Hred.iHVal / 2, Sred.iHVal2.55, Vred.iHVal*2.55), imgThresholded); erode(imgThresholded, imgThresholded, getStructuringElement(MORPH_ELLIPSE, Size(3, 3))); dilate(imgThresholded, imgThresholded, getStructuringElement(MORPH_ELLIPSE, Size(3, 3))); //morphological closing (fill small holes in the foreground) dilate(imgThresholded, imgThresholded, getStructuringElement(MORPH_ELLIPSE, Size(3, 3))); erode(imgThresholded, imgThresholded, getStructuringElement(MORPH_ELLIPSE, Size(3, 3))); imshow(thhdWindow, imgThresholded); }

Same output threshold image

I use three filter as below, each one if I run individual work well(three output image 'imgThresholded' is difference), but if I use continuously all, the output image 'imgThresholded' is the last one.

void filterBlack(){ inRange(imgHSV, Scalar(Hblack.iLVal / 2, Sblack.iLVal, Vblack.iLVal2.55), Scalar(Hblack.iHVal / 2, Sblack.iHVal2.55, Vblack.iHVal2.55), Vblack.iHVal*2.55), imgThresholded); erode(imgThresholded, imgThresholded, getStructuringElement(MORPH_ELLIPSE, Size(3, 3))); dilate(imgThresholded, imgThresholded, getStructuringElement(MORPH_ELLIPSE, Size(3, 3))); //morphological closing (fill small holes in the foreground) dilate(imgThresholded, imgThresholded, getStructuringElement(MORPH_ELLIPSE, Size(3, 3))); erode(imgThresholded, imgThresholded, getStructuringElement(MORPH_ELLIPSE, Size(3, 3))); imshow(thhdWindow, imgThresholded); } }

void filterBlue(){ inRange(imgHSV, Scalar(Hblue.iLVal / 2, Sblue.iLVal, Vblue.iLVal2.55), Scalar(Hblue.iHVal / 2, Sblue.iHVal2.55, Vblue.iHVal2.55), Vblue.iHVal*2.55), imgThresholded); erode(imgThresholded, imgThresholded, getStructuringElement(MORPH_ELLIPSE, Size(3, 3))); dilate(imgThresholded, imgThresholded, getStructuringElement(MORPH_ELLIPSE, Size(3, 3))); //morphological closing (fill small holes in the foreground) dilate(imgThresholded, imgThresholded, getStructuringElement(MORPH_ELLIPSE, Size(3, 3))); erode(imgThresholded, imgThresholded, getStructuringElement(MORPH_ELLIPSE, Size(3, 3))); imshow(thhdWindow, imgThresholded); } }

void filterRed(){ inRange(imgHSV, Scalar(Hred.iLVal / 2, Sred.iLVal, Vred.iLVal2.55), Scalar(Hred.iHVal / 2, Sred.iHVal2.55, Vred.iHVal*2.55), imgThresholded); erode(imgThresholded, imgThresholded, getStructuringElement(MORPH_ELLIPSE, Size(3, 3))); dilate(imgThresholded, imgThresholded, getStructuringElement(MORPH_ELLIPSE, Size(3, 3))); //morphological closing (fill small holes in the foreground) dilate(imgThresholded, imgThresholded, getStructuringElement(MORPH_ELLIPSE, Size(3, 3))); erode(imgThresholded, imgThresholded, getStructuringElement(MORPH_ELLIPSE, Size(3, 3))); imshow(thhdWindow, imgThresholded); }

Same output threshold image

I use three filter as below, each one if I run individual work well(three output image 'imgThresholded' is difference), but if I use continuously all, the output image 'imgThresholded' is the last one.

void filterBlack(){
    inRange(imgHSV, Scalar(Hblack.iLVal / 2, Sblack.iLVal, Vblack.iLVal2.55), Vblack.iLVal*2.55), Scalar(Hblack.iHVal / 2, Sblack.iHVal2.55, Sblack.iHVal*2.55, Vblack.iHVal*2.55), imgThresholded);
    erode(imgThresholded, imgThresholded, getStructuringElement(MORPH_ELLIPSE, Size(3, 3)));
    dilate(imgThresholded, imgThresholded, getStructuringElement(MORPH_ELLIPSE, Size(3, 3)));
    //morphological closing (fill small holes in the foreground)
    dilate(imgThresholded, imgThresholded, getStructuringElement(MORPH_ELLIPSE, Size(3, 3)));
    erode(imgThresholded, imgThresholded, getStructuringElement(MORPH_ELLIPSE, Size(3, 3)));
    imshow(thhdWindow, imgThresholded);
}

} void filterBlue(){ inRange(imgHSV, Scalar(Hblue.iLVal / 2, Sblue.iLVal, Vblue.iLVal2.55), Vblue.iLVal*2.55), Scalar(Hblue.iHVal / 2, Sblue.iHVal2.55, Sblue.iHVal*2.55, Vblue.iHVal*2.55), imgThresholded); erode(imgThresholded, imgThresholded, getStructuringElement(MORPH_ELLIPSE, Size(3, 3))); dilate(imgThresholded, imgThresholded, getStructuringElement(MORPH_ELLIPSE, Size(3, 3))); //morphological closing (fill small holes in the foreground) dilate(imgThresholded, imgThresholded, getStructuringElement(MORPH_ELLIPSE, Size(3, 3))); erode(imgThresholded, imgThresholded, getStructuringElement(MORPH_ELLIPSE, Size(3, 3))); imshow(thhdWindow, imgThresholded); }

} void filterRed(){ inRange(imgHSV, Scalar(Hred.iLVal / 2, Sred.iLVal, Vred.iLVal2.55), Vred.iLVal*2.55), Scalar(Hred.iHVal / 2, Sred.iHVal2.55, Sred.iHVal*2.55, Vred.iHVal*2.55), imgThresholded); erode(imgThresholded, imgThresholded, getStructuringElement(MORPH_ELLIPSE, Size(3, 3))); dilate(imgThresholded, imgThresholded, getStructuringElement(MORPH_ELLIPSE, Size(3, 3))); //morphological closing (fill small holes in the foreground) dilate(imgThresholded, imgThresholded, getStructuringElement(MORPH_ELLIPSE, Size(3, 3))); erode(imgThresholded, imgThresholded, getStructuringElement(MORPH_ELLIPSE, Size(3, 3))); imshow(thhdWindow, imgThresholded); }

}