How to create a flood fill figure animation using python? - python

How to create flood fill figure animation using python?
I saw this image online and was wondering how to go about these types of animation. I think this is a very useful technique that can be used in maps, presentations, etc and was curious about it.
The image:
http://i.imgur.com/zaSxkLI.gif
I Researched these questions:
Flood Fill in Python
How to flood-fill part of a bitmap enclosed by a black border with my chosen color?
Python: floodfill algorithm for minesweeper
Flood Fill Algorithm Python
Looked at this resource:
http://inventwithpython.com/blog/2011/08/11/recursion-explained-with-the-flood-fill-algorithm-and-zombies-and-cats/
Questions:
Can you point me to working code that does this type of exercise?
Which libraries are considered standard to use now?
How does the logic behind the fill exercise work?
Can you point me to more information/resources (maybe the docs for the libraries)
How could I integrate this concept with matplotlib? Can you point me to an example?
Thank you so much!

Related

Interactive circle annotation on image to replicate Matlab's drawcircle function

In the past I haveused Matlab's drawcircle function to interactively draw a circle on an image as a method of measuring the radius of a circular feature which is very hard to extract using circle-detection algorithms.
I am trying to make the switch over to python (making use of matplotlib and cv2 etc.), but am struggling to find any way replicating this functionality.
Is this sort of interactive annotation at all possible in Python/Matplotlib/openCV/other? Or would it be better to leave this idea behind and go down the route of iteratively entering coordinates/radius into the console?

How to track a real track image, for race Level design?

i am creating a game using pygame and python.
i have develoved a square that goes up and down, flows a path.
how do i set a particular path for the square?
My question is how do i take this image and convert it into a path equation the square follows?
Any other idea to use this or any track from an image is appreciated.
i tried imread() of matlab and many other things. i dont think grayscale applies here. i even tried superimposing it on a grid and plot points along the track.
i am out of ideas and from all the vedios i have seen i am missing something very basic here i think. any help?

Best way to isolate a Rubik's Cube from background

I have been working on a python program using opencv that will help the user solve the Rubik's Cube. The most important & complicated part is identifying the cube to read the value of each of its sides.
I have had a decent amount of luck so far but am wanting to change the processing pipeline a little. I think it would make sense to isolate the cube from its background before trying to detect the (rounded) square stickers and read their colors.
Attached is an example of the sort of frame we would be dealing with. I'm not sure what the best method for isolating the cube from the background would be. I have tried background selection, which seemed somewhat promising (though the mask was very grainy & blotchy). But I am also wondering if it would make more sense to use something like object detection.
I have considered just making a "dumb" crop which makes the user align the cube within a reticle. However, I would prefer a more elegant solution and don't mind spending the additional time that entails.
Edit: maybe the mild bokeh could be used to identify the background, or is it too miniscule to detect consistently?
Thanks for any help!

how to overlay 3d objects on webcam with opencv and python?

I want to overlay 3d objects on live webcam for my project. I have overlayed 2d objects like googles, mustache, and hat. Now I want to overlay 3d objects like beard, mustache, and hair. I searched over some articles and tutorials, but all of them were ambiguous and didn't teach where to start. From what I have learned I need to create 3d objects using blender and import it using OpenGL and then somehow overlay it to the facial landmarks. I want to know what I need to learn to achieve this objective. I have read the previous question on this source1 and it didn't help much. Also, I have read several blogs like this,
this, and the best one here and various others while surfing. I know I am entering into AR/VR, but I ready to learn the things required to get my work done.
There are various libraries/frameworks which don't require to code anything like SparkAR, Virtualtryon, ditto, etc. but they don't teach you anything. I want to learn how to do these things by myself. If I create my 3d object like hair(hair-like Goku in SuperSaiyan)/Mustache or eyes in blender how can I overlay it in real-time on webcam using OpenCV or any other python compatible lib/framework? I mean overlaying 3d hair over my own hair, overlaying 3d eyes over my eyes and similar. What are the things required to do such a task? What things do I need to learn?

something like gimp "fuzzy select" in python/PIL

I have image with some object at not solid background. I want to extract this objects like in gimp using "fuzzy select". This can be an example:
http://img249.imageshack.us/gal.php?g=25750902.png
Question is what is the best way to do it using python/PIL...
I suppose you would need some flood-fill algorithm (such as breadth-first-traversal) in which you stop exploring pixels with different color than black.
Wikipedia has an excellent explanation with animations and pseudo-code
http://en.wikipedia.org/wiki/Flood_fill
And besides, if you want to add feature like "tolerance" in Photoshop, you should apply this method Connected-component_labeling when getting connected vertex on your graph while doing flood fill
As of today, skimage 0.19 has a flood fill algorithm: link

Categories

Resources