Ask Your Question
0

Obtaining coordinates of pixels lighted at specific color

asked 2015-01-07 05:55:51 -0500

jiarongkoh gravatar image

updated 2015-01-07 05:58:27 -0500

Hi everyone, I am working on an app using OpenCV249 on android and would like to find means to obtain the coordinates of the pixels that are lighted at a specific color relative to the image. For instance if I draw a green dot using android's canvas and drawables on an image, is there a way to obtain the coordinates of that green dot relative to the image?

And if this process is extended to more complicated random sketches, ie circles or rectangles, is there a way to obtain those points as well? Do note that I am developing for android, thanks!

edit retag flag offensive close merge delete

Comments

How did you draw it? If you draw it, I am afraid that you need its coordinates. If you have some colors and you need to fing the coordinate, then I think you shall use HSV and get the saturation and then the moments would help you.

thdrksdfthmn gravatar imagethdrksdfthmn ( 2015-01-07 06:30:17 -0500 )edit

Basically when you draw something first in software then you know exactly what color is being used by its RGB values. So why not apply basic thresholding of the image on those values? That will render a binary mask of everything you have drawn.

StevenPuttemans gravatar imageStevenPuttemans ( 2015-01-07 06:35:44 -0500 )edit
1

Hi @thdrksdfthmn thanks for replying. Pls pardon me I don quite get what you said. I drew it using the android's Canvas and Drawables method with the finger as the input. So you can imagine it as a doodling app. I can't seem to find methods on the java api that deals with HSV and moments, do you mind elaborating abit more on your approach?

jiarongkoh gravatar imagejiarongkoh ( 2015-01-07 06:39:53 -0500 )edit
1

For conversion you can see this. But maybe there is a better to do as Steven sais... thresholding

thdrksdfthmn gravatar imagethdrksdfthmn ( 2015-01-07 07:02:12 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2015-01-12 14:01:41 -0500

What about Core.inRange and Imgproc.findContours? The first will remove all pixels with another color and findContours will find the connected components of the remaining pixels.

edit flag offensive delete link more

Comments

@FooBar Thanks for your reply. I'm experimenting on the Core.inRange() but am having a little difficulty understanding it. I'm employing this: Core.inRange(image, new Scalar(0, 0, 0), new Scalar(0, 0, 0), displayimage); then <display the="" displayimage="">

What I understand from the docs is that the inRange() method displays any pixel within the range of the upperbound and lowerbound to be white. So for my case, any pixel with the BGR of 0,0,0 (which is black) will be displayed as white. Am I right to say that? If so, this method isn't giving me what it should be. In fact, it lights every pixel in image to black. Any idea where have I gone wrong?

jiarongkoh gravatar imagejiarongkoh ( 2015-01-14 07:21:58 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2015-01-07 05:55:51 -0500

Seen: 1,149 times

Last updated: Jan 12 '15