Ask Your Question
0

Converting image into an array of 2D coordinate points and colors

asked 2017-02-19 14:17:03 -0600

So, Hello everyone. I am working on a project and need a little help. I have a base code for a machine that can move a pneumatic piston to a coordinate on a 2d plane. It also has functions to be able to select a color (based off a var) and select that color by moving the piston up and down over a pallet and then goes to the coordinates provided in the variable. The machine is coded in C and basically it needs to convert lets say a .jpeg image into this format when it converts i want it to be basically a notepad document with this inside: blue[32,3],red[25,56],yellow[4,7],blue[7,9],red[2,3],yellow[25,56]

And so then the machine would run at x32 and z3 to put down the color blue, clean the brush and then continue on to the next. Also it can create the different colors like purple and such on the side then once it knows it is created the purple, orange, and green functions can be used in the program. That i can code in. If anyone can help that would be great thank you! :)

edit retag flag offensive close merge delete

Comments

So, there's a couple of steps here.

First, there is the question of what colors to use. Do you want to posterize the image to a small set of colors and create those, or do you want a pre-defined set of colors and convert the image to just those colors?

Secondly, there is order. From what you say, the machine might benefit from having the colors in order, so it does all the blue, then all the red, then all the green and so forth. That would save having to clean the brush every time, maybe.

Third, what resolution images and what resolution is the machine? Do you need to resize the images, to fit, or are they already the appropriate size?

Last, do you know enough C++ that if you knew the color and coordinate you could print it, or are you a total beginner?

Tetragramm gravatar imageTetragramm ( 2017-02-19 15:18:02 -0600 )edit

Thank you for responding Tetragramm. I am limited to 8 premixed colors during the entire process. so i would want the primary colors, then depending on the image that i would be converting i would select the next 6.

Yes i do think all blue then al red etc would be best for time (even though it is not a variable in this project) I think that would be best not to have water accidentally spill on the work when it moves from clean to color.

I can get the dimensions of the sheet on Tuesday (currently Sunday when I am posting) I am currently out of town. But once i get the dimensions on what the machine can print on. I would say keep i want to keep the photo at a low resolution for the use of only having 8 colors to be used.

So again i specified ...(more)

Respawn_101 gravatar imageRespawn_101 ( 2017-03-12 23:31:52 -0600 )edit

And not i am not a beginner in C or C++ i am how ever in OPenCV (which the only reason i am posting is because I thought OpenCV to be an imaging processing open source software) Any help would be greatly appreciated. i Also have access to adobe illustrator for image tracing, and or reducing color amounts and resolution. But i don't know if that would help :)

Respawn_101 gravatar imageRespawn_101 ( 2017-03-12 23:32:12 -0600 )edit

Pardon my english :)

Respawn_101 gravatar imageRespawn_101 ( 2017-03-12 23:32:29 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-03-13 17:42:58 -0600

Tetragramm gravatar image

Well, OpenCV is an image processing library, but most of what you need to do is not really image processing.

To make the image lower resolution, you can see an example in THIS tutorial.

And to reduce the number of colors, THESE tutorials explain how kmeans works and how to use it for posterizing the image. There is also the kmeans.cpp sample code to show how to use kmeans in C++ instead of Python.

Then it's just a matter of checking which color each pixel is and then adding it to the appropriate list and printing the lists to a file.

Of course, if you use adobe illustrator for reducing colors and resolution, you don't really need OpenCV at all, except possibly to read the image, which is trivial.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-02-19 14:17:03 -0600

Seen: 1,642 times

Last updated: Mar 13 '17