ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Process images

asked 2014-08-04 09:08:35 -0500

I don't know much about computer vision but what I have to do is pretty simple (At least, it is what I was told).

I want to identify red color on the image, and I have read that the first step is to process the image (before the thresholding) but I don't know which filters or operations are usually made. I have already done the cv_bridge transformation to OpenCV format and the threlholding.

Does anyone know anything about it? Thank you

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2014-08-04 21:17:45 -0500

Mehdi. gravatar image

updated 2014-08-04 23:59:38 -0500

What you are looking for is probably the BGR2HSV transformation. HSV is a color space where you can easily filter out a color you need. Under python the function to transform an image from BGR to HSV is called cv2.cvtColor

The function to filter your image for one set of Hue, Saturation and Value parameters is cv2.inRange

You need to find out the right Hue, Saturation and Value parameters for your color by testing, starting with values you get by converting the closest RGB color to what you need (red 0,0,255) to HSV and then tuning the values.

After filtering you will get an image with a blob of white pixels which represent the color. You can see an example here with a pink ball

in C++ it would look like that :

cv_bridge::CvImagePtr cv_ptr;
Mat HSVImage;
Mat ThreshImage;
// transform ROS image into OpenCV image
cv_ptr = cv_bridge::toCvCopy(msg, enc::BGR8);
//Transform the colors into HSV
cvtColor(cv_ptr->image,HSVImage,CV_BGR2HSV);
//for blue
inRange(HSVImage,Scalar(80,90,70),Scalar(110,125,200),ThreshImage);

here I found out that the blue of the ball I wanted the robot to track was between (80,90,70) and (110,125,200) HSV values.

edit flag offensive delete link more

Comments

I have already done it, but I have read that is pretty interesting to filter the image to reduce noise before converting it. Thank you

arenillas gravatar image arenillas  ( 2014-08-05 05:58:26 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2014-08-04 09:08:35 -0500

Seen: 2,248 times

Last updated: Aug 04 '14