An efficient detection method for rare colored capsule based on RGB and HSV color space

Rare colored capsule (RCC) is the capsule which is mixed in the normal product but with different color. To detect this kind of capsules online, a method based on RGB color space and using HSV color difference formula is proposed in this paper. Considering HSV color space with more balanced color-difference perception, the original RGB formatted capsule image is transformed to HSV color space for accurate detection. To guarantee the on-line detection efficiency, the color space transformation and the color difference calculation are not on pixel level. A set of R, G, B component values are acquired to represent the color of the capsule by a novel average gray calculation method based on histogram. Thus the RGB to HSV transformation is only need to process the set of R, G and B component values. The transformed H, S and V component values are then applied to calculate the color difference. By comparing the color difference with the given threshold, the final detection result for RCC is achieved. Compared with the usual color recognition method based on HSV, which transform color space in the whole image, the presented method is time saving. Online test results show that the proposed method has high accuracy and efficiency.