Alright guys..
I'm at a loss here. I've been trying to code an image to polygon converter to no avail, it's really bugging me. It's supposed to create a polygon from the transparency of an image (the non transparent part is the polygon). I've seen programs that do it, but they were closed-source and really expensive. It's not just edge-detection, it's polygon generalization and hole-detection as well, all this in a Box2D compatible, triangulated polygon.
Please hand me some tips on this, or a library name, or an algorithm or something..
Thanks!
I suggest looking at the openCV library. It has several useful algorithms and tools for
image processing. I think you can accomplish your goal with it.
Good luck.
Related
I am going to split this question in 3 parts
First, I've been given this problem, and I don't know where to start, if you have been solving related problem, would you give me some hints and keywords to help me do some more research?
I have done some research on my own
So here is some 2D chest CT scans (sorry due to reputation rule i can't implement images directly)
All photos are in the same angle. So I think I can simply read each photo to a vector of pixels, do some thresh holding to make all black and black-ish pixels going to be a non-colored pixel. Next, I'll create a vector called vector_of_photo of those vectors. Then the index of each vector in vector_of_photo are now the Z-index.
Now I can render a 3d photo from those vectors of pixels right?
In the second place, I got trouble understand raycasting algorithm,
I think the idea here is, when I already got a box of pixel then everytime I rotate the box, it cast straight-lines from that angle of the camera to the box, each line found a has-colored pixel going to stop casting and render that pixel (or more specific, copy the pixel to the exactly location on the plane).
Did I understand it correctly?
At last, the OPENGL/c++ part is just the option I think I'm going to use to solve this problem. And I'm not pretty sure it is a good idea or not, so give me some more hint about the programming language, library or module I should take a look at.
I happen to be working on the same problem in my spare time. Haha :)
Here is one approach to your problem:
Load the images into your application, such that you get the 3D volumetric dataset that you describe
Remove all points that don't fit within some range of values (e.g. 0.4/1.0 to 0.6/1.0 brightness). You may need to apply preprocessing and filtering.
Fit a mesh to the resulting point cloud with open-source software. Here is a good blog post about that
https://towardsdatascience.com/5-step-guide-to-generate-3d-meshes-from-point-clouds-with-python-36bad397d8ba
Take the resulting mesh (probably, an STL file) and visualize it in any software your want (Blender 3D, Unity 3D, Cinema 4D, a custom OpenGL application), anything really.
My own approach to this problem is very similar to the one you suggest in your question, and I have already made some headway. Therefore, I thought it would be good to suggest another route.
NOTE Please be aware that what you are working on is not a trivial problem. It's a large project, and there are many Commerical companies that put years into doing just this. This is a great project for learning OpenGL, rendering, and other concepts. It's perfectly doable, but you may be looking at several months of work, and lots of trial and error. Good luck!
Its not often that two people would happen to work on the same problem, so if you want to discuss further, feel free to contact me over linkedin and/or post a comment below. www.linkedin.com/in/michael-sohnen-a2454b1b2
I am looking for an efficient algorithm or library capable of rasterizing 2d shape defined by a set of lines and curves. So far, what I found do the reverse from what I need ,others are overkill (ImageMagic ,Cairo) .I am interested in a compact utility. Anyone can point out to the right direction?
Rasterization of 2d shapes is not a trivial matter, especially if it includes Bézier curves. Here are some libraries you may want to try:
Cairo
skia
Anti-Grain Geometry, also here
Poppler
mupdf
Ghostscript
libxmi (does not handle Bézier curves)
See also
Good SVG renderer for Linux?
You're looking for "vectorization," and you can find quite a bit of it around by googling:
potrace is probably what you want:
http://potrace.sourceforge.net/
http://en.wikipedia.org/wiki/Vectorization_(image_tracing)
http://autotrace.sourceforge.net/
http://inkscape.org/
I'm wondering if anyone could point me to any resources that would deal in rotating one or several 2D textured planes in 3D space. Something like this but with openGL (preferably C++):
I'm attempting to do pretty much the exact same thing but no matter how I order my operations I'm getting right-screwy results. So I figure asking for some resources on the subject is better than posting tons of code and asking for people to fix my problems for me. :)
If you havent already, do a search for 'NeHe tutorials'. An excellent set of OpenGL tutorials.
Here is a link to the rotation tutorial, includes all the source code in downloadable format and the tutorial walks you through each relevant line.
http://nehe.gamedev.net/tutorial/rotation/14001/
I believe this is working in a 2D space, the step up to 3D probably involves a bit more matrix math but...doable
The NeHe tutorials are a very popular place to learn the basics of OpenGL. In particular, the tutorial about texture mapping should help you:
http://nehe.gamedev.net/tutorial/texture_mapping/12038/
Mind you though that these tutorials are written for older OpenGL versions which are more beginner friendly IMHO.
You should look into scene graphs. Basically it is a way to define a bunch of objects (2D textured planes) and their transforms in 3D space. This allows you to define transforms that work on multiple nodes (objects) as well as single nodes. You can make a pretty simple one in C++ with little effort, or use one such as OpenSG or OSG (slight learning curve needed).
Wikipedia - http://en.wikipedia.org/wiki/Scene_graph
is there anyway to build rich animation with C++?
I have been using OpenCV for object detection, and I want to show the detected object with rich animation, Is there any easy way to realize this?
I know flash can be used to easily build rich animation. But can flash be reliably integrated with C++ and How?
Also, Can OpenGL help me with this? To my knowledge, OpenGL is good for 3D rendering. But I am more interested in showing 2D animations in an image. So I am not sure whether this is a right way to go.
Another question, how are those animations in augmented reality realized? What kind of library are they using?
Thank you in advance.
Its difficult to tell if this answer will be relevant, but depending on what sort of application you are creating you may be able to use Simple DirectMedia Layer.
This is a cross-platform 2D and 3D (via OpenGL) media library for C, C++ and many other compatible languages.
It appears to me that you wish to produce an animated demo of your processing results. If I am wrong, let me know.
The simplest way to produce a demo of a vision algorithm is to dump the results to a distinct image file after each processed frame. After the processing session, these individual image files are employed to prepare the video using e.g. mencoder. I employed such procedure to prepare this.
Of course, your program can also produce OpenGL. Many people dealing with 3D reconstruction do that. However, in my opinion that would be an overkill for simple 2D detection. Producing flash would be an even greater overkill.
I am a newbie and i would like to give artistic effects to the images such as photocopy , blur ,glow edge, mosaic bubble ,pencil sketch ,marker , glass effect,paint brush,glow diffused effect programatically?
I want to implement it and any input is appreciated.
The following link depicts what i want to do exactly...
http://picasaweb.google.com/ashish.j.soni/BloggerPictures?authkey=Gv1sRgCMPHzP2P_fjRlgE#5413931800038472178
I believe that these effects are implemented in the GIMP.
The source code is available online http://www.gimp.org/source/ This may help you see how such algorithms are implemented.
You should check OpenCV, it will make your life easier. It is aimed at real-time computer vision, Not really what you are after, but it has a lot of useful functionality (eg. opening/saving different image formats) and standard image operations.
Matlab/octave is also a good tool to get feeling with image processing algorithms.