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

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?

Related

How to calculate a facial point grid using OpenCV and Python?

I'm trying to automatically draw a mesh or grid over a face, similar to the image below, to use the result in a blog post that I'm writing. However, my knowledge of computer vision is not enough to recognize which model or algorithm is behind these types of cool visualizations.
Could someone help pointing me some link to reador or a starting point?
Using Python, OpenCV and dlib the closest thing I found is something called delauny triangulation but I'm not sure if that's exactly what I'm looking for seeing the results.
Putting it in a few words what I have so far is:
Detect all faces on image and calculate their landmarks using dlib.get_frontal_face_detector() and dlib.shape_predictor() methods from dlib.
Use the method cv2.Subdiv2D() from OpenCV to compute a 2D subdivision based on my landmarks. In particulary I'm getting the delauny subdivision using the getTriangleList() method from the resulting subdivision.
The complete code is available here.
However, the result is not so attractive perhaps because the division is using triangles instead of polygons and I want to check if I can improve it!

Display an image with pixel values shown numerically

I'm looking for OpenCV or other Python function that displays a NumPy array as an image like this:
Referenced from this tutorial.
What function creates this kind of grey-scale image with pixel values display?
Is there a color image equivalent?
MATLAB has a function called showPixelValues().
The best way to do this is to search "heat map" or "confusion matrix" rather than image, then there are two good options:
Using matplotlib only, with imshow() and text() as building blocks the solution is actually not that hard, and here are some examples.
Using seaborn which is a data visualisation package and the solution is essentially a one-liner using seaborn.heatmap() as shown in these examples.
My problem was really tunnel vision, coming at it from an image processing mindset, and not thinking about what other communities have a need to display the same thing even if they call it by a different name.

Is there a Python function to compute isosurface end-cap geometry like the 'isocaps' function in Matlab?

I want to get some 3D models defined by implicit functions like F(x,y,z)=0.
It can be done using the 'isosurface' and 'isocaps' functions in MATLAB.
In my case, the constructed models need post-process in Python so it would be better if the modelling can be done in Python.
'mayavi.mlab.Contour3d' and 'plotly.graph_objects.Isosurface' are able to display the isosurface while 'skimage.measure.marching_cubes' can be used to extract the trangler mesh.
Can anyone help me find a way in Python to get the isosurface end-cap?
I'm looking for a way to do the exact same thing. Another user gave me the following solution for my own request.
Is there a way to fill one side of the gyroid surface by using Mayavi?
You have to use an extra tool for visualization to do it. I'm using Mayavi for generating the structures I need but I can't get the surface end-cap by using it.
Maybe the answer to my question can help you out.

Do I need to use OpenGL to draw at the pixel by pixel level (Python). Is there a way I can do such a thing without using a code library?

I have written some code in Python which allows 3D objects to be defined in 3D object space and mapped onto a 2D screen. Currently the finished 2D polygons are drawn on the screen using the PyGame library, which works effectively, but I would like to go the full way and write code myself to complete the drawing operations PyGame does for me. This means I would like to manually control the drawing of each pixel on the screen, with the use of GPU support to accelerate the entire rendering process. From some reading it seems OpenGL is suitable for this sort of thing, but I'm not sure what the complete purpose of OpenGL is and whether I could achieve what I am trying to do in a better way. Do I really need to use OpenGL? Or is there another way for me to directly access my GPU to draw at the pixel by pixel level?
It sounds like OpenGL's programmable shaders are what you're looking for (in particular fragment shaders). They run massively parallel on a pixel-by-pixel basis, in the sense that basically you write a function that takes a single pixel location and computes its color. Note that this means that the individual pixels can't exchange information, though there are certain ways around that.
(Technically when I said "pixel" I meant "fragment", which is sort of a generalized version of a pixel.)

How to create a flood fill figure animation using 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!

Categories

Resources