Ask Your Question
0

How to detect white color in threshold image

asked 2017-08-21 09:52:35 -0600

esconda gravatar image

Hello everyone, Nowadays I am trying to detect red color objects on the images with given basic codes;

cv::Mat lower_red_hue_range; cv::Mat upper_red_hue_range; cv::inRange(hsv_image, cv::Scalar(0, 100, 100), cv::Scalar(10, 255, 255), lower_red_hue_range); cv::inRange(hsv_image, cv::Scalar(160, 100, 100), cv::Scalar(179, 255, 255), upper_red_hue_range);

After this operation I am using bitwise or an get threshold image with red color area with white scalar value like this.

image description

Everything is fine, as you see I already found red parts of the image in bitwise or.According to Bitwise-or threshold image, ı have to detect and find available white area.I should need it to check if there is a red color area on the image for analyzing.Because my program gets error if there is no red color object on the image.

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
1

answered 2017-08-21 19:24:07 -0600

Ziri gravatar image

If you want to check if you have white pixels or not use :

countNonZero(InputArray src)

If you want to check white pixels position and area ...etc you have to do blob processing : findContours

edit flag offensive delete link more

Comments

As you mentioned I just want to check white pixels and I will create a query

esconda gravatar imageesconda ( 2017-08-22 01:25:27 -0600 )edit

Thank you man I solved it with "countNonZero(InputArray src)" :)

esconda gravatar imageesconda ( 2017-08-22 01:37:39 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2017-08-21 09:52:35 -0600

Seen: 6,807 times

Last updated: Aug 21 '17