Home>
Premise

Red detection is performed by C # and OpenCV (OpenCVSharp).


Looking at the image just before detection, is it a minute noise? Something that seems to be there is scattered.


The target red color can be detected, but noise is also detected at the same time, so
It is avoided by the filter at the time of detection (the size of the detected area).

The problem i am having

I don't know why noise is generated in the first place,
If the noise generated is larger than the filter at the time of detection, and it is necessary to take measures,
We are looking for a way to remove the noise a little more.

Thank you.

Corresponding source code

In particular, no errors have occurred at present, but it is a series of steps up to detection.

Flow (excerpt)

Cv2.CvtColor (_srcImage, hsvImage, ColorConversionCodes.BGR2HSV);
Cv2.LUT (hsvImage, _colorFilter.LookupTable, hsvImage);
Cv2.BitwiseAnd (channelImage2 [0], channelImage [1], _filterdImage);
Cv2.BitwiseAnd (_filterdImage, channelImage [2], _filterdImage);
Cv2.CvtColor (_filterdImage, grayImage, ColorConversionCodes.BGR2GRAY);
Cv2.Threshold (grayImage, grayImage, 1, 255, ThresholdTypes.Binary);
blobs.Label (grayImage);
blobs.FilterByArea (filterSize, int.MaxValue);

HSV setting

H: 315 ~ 20
S: 30-255
V: 30-255

What I tried

Change color range, change parameters during extraction