Image Analysis in Bokeh? - python

I am looking to replace a MATLAB GUI used to do manual scoring of objects within a tif file. Someone recommended Bokeh to me. Is it possible to read a tif-file using any module and allow interactivity via Bokeh?

I have not used Bokeh (but I have kept an eye on it), so my answer is: Yes, you could probably use Bokeh for this.
But considering that you are replacing a MATLAB GUI, I think there might be an easier way. Bokeh creates plots that run in your web browser, which might not be what you want.
Instead, you could look into using matplotlib to do it.
The PyPlot API in matplotlib is very similar to the plot functions in MATLAB, and it supports creating interactive plots.
To read the TIFF file I would recommend looking into either PIL or OpenCV.

Related

Can the plotly.io.write_html be used to also plot images?

Usually, we use the line to plot graphs and confusion matrices. However, the official documentation doesn't really specify which types of figures are supported.
Can I actually use it for image files?
(I tried using it but it doesn't run properly, I don't know whether it was because of it not supporting it)
Based on the documentation, it supports a fig meaning a plotly figure object.
Unless you create a plotly figure object containing your image, you won't be able to use plotly.io.write_html(fig, ...)

Is there a Matplotlib equivalent to the Borland C command putpixel?

I am interested in porting some of my old fractal imaging programs over from Borland C to python. In Borland C, the putpixel command would place a specified color pixel within a rasterized graphical field. Is there a simple way to do this in matplotlib?
So the answer depends on what you're trying to do here. matplotlib has a lot of utilities for working with representing image data, this might give a good starting point for getting familiar with matplotlib's workflow. You can directly edit the values of the numpy array that you're using matplotlib to visualize, but matplotlib doesn't give you access to the data that you're rendering.
I imagine that you already have written some colormap and other rendering tools tools, but to get an idea of what matplotlib might have built in, I recommend looking at this example. It's a simple Mandelbrot, escape time, but it makes use of nonlinear colormapping and shading.
In my experience, I've normally computed the fractal as a 2D numpy array, and then allowed matplotlib to handle the coloring, and scaling of the final output image. Matplotlib doesn't work like the canvas experience it sounds like you're used to using. I'd recommend filling a numpy array with the desired pixel values as you've computed them, and then sending that array off to matplotlib to be rendered.
After posting this I discovered that there is a putpixel command in PIL (Python Imaging Library), which has tools for dealing with pixel oriented graphics. Matplotlib can also do the job as suggested by the answer above.

Python: Small library for 3d-surface plots without dependencies to Matplotlib/Numpy

I need to deploy my python code as an .exe-file, which should generate quite a lot of 3d surface plots. Because of the deployment, I cannot use any library which relies on either Numpy, Pandas, Matplotlib etc, because this will cause huge filesizes of the .exe.
Unfortunately, plotly and bokeh only work well in the browser, i.e. generate interactive plots. To make a jpg/png from there, I'd need to also embed selenium browser into my exe for bokeh which is not really what I'm looking for.
That's why I'm wondering whether you know a "lean" (i.e.: small) library to generate surface plots? Apart from that, most of these heavy customization-possibilities are not needed at all, simply a good style and that's it.
Any ideas?
Thanks!

UI Adjustable Matplotlib Color Range

I am using Python's scientific plotting library matplotlib. I am trying to use matplotlib to show an image using imshow. I would like to be able to adjust the color range with in the figure with some type of UI. From what I can tell, there isn't a built-in way to do this in matplotlib, and I have found much on this issue. This is a fairly common use-case and easy to do in MATLAB. How does one do this in matplotlib?
I'm assuming you want to change the cmap attribute. You could use the built-in function input to read some new value from the command line (not really a GUI) or you could use the matplotlib.widgets package which includes e.g. a slider and buttons (see this link for examples).

Tool to create a python GUI for graph construction

I need to create a GUI for graph construction ("graph" as an abstract representation of a set of objects, not a visual representation of data). The interface will provide a choice of ~5 vertex types and of ~5 edge types. Each vertex will have two data fields: a text label and a file name, which need to be easily editable.
I'm familiar with igraph and have a lot of code written in it. I will use igraph to manipulate the graphs created with this GUI.
Since this will be my first GUI, I'm completely ignorant of what tools are available. Can you please suggest a free library, knowing that eventually the program will need to work on Windows?
EDIT
it seems from the answers I get that I wasn't clear enough. I'm not looking for a way to visualize a graph, but rather for a way to visually create one. By visually, I mean not needing to manually create text files or writing code.
Take a look at xdot.py.
From the homepage
xdot.py is an interactive viewer for graphs written in Graphviz's
dot language.
It uses internally the graphviz's xdot output format as an
intermediate format, and PyGTK and Cairo for rendering.
xdot.py can be used either as a standalone application from
command line, or as a library embedded in your python application.
I like networkx,
from networkx import draw, Graph
from pylab import show
g = Graph()
g.add_edges_from([(1,2),(1,3),(2,4),(2,5)])
draw(g)
show()
which gives,
The only quirk is the requirement for matplotlib to get builtin plotting to work.
If you use python, I think PyQt is a good selection.
What you have to install is listed below:
install Python from here
install PyQt4 from here
But it takes many lines to write GUI application,
it is sometimes better to generate an image to display with image viewer.

Categories

Resources