matlab's imshow3d mouse scrolling image visualization in python - python

Currently, I am trying to build a User Interface with python to visualize MRI images (in numpy) in 'tkinter' Graphic User Interface.
The feature of mouse scrolling from Matlab's imshow3d is essential but I was not able to find anything like this on web (ex.https://www.mathworks.com/matlabcentral/mlcdownloads/downloads/submissions/47463/versions/3/screenshot.jpg).
Does anyone have any idea how I can implement the mouse based slice browsing with tkinter?
or are there any other gui that I could use to build what I want.

Related

2d graphics in Python Kivy, advice is needed

I still have been studying world of Kivy and I have encountered with question. I am designing an interface. it has to have an appearance of analog device with arrow and curved scale like old voltmeters were. Just to display a data on the screen. I've tried to use canvas, but I stacked with resizing of window properties. Built canvas object was either connected to specific size in px, or changed location on the screen in wrong way. So, I am curious, maybe here are some others ways to embed objects which were built in another 2d graphics library, I am aware of existence of 3d module vpython and turtle. Maybe we have some more?
Can anybody give me a hint? I would be very grateful
kivy, canvas
view of my prototype
You can use Image widgets combined with Button Behavior or ToggleButton Behavior to make buttons that look like almost any kind of button that you like. And you can make a curved scale as described in this question.

Graphics library to draw images to screen for python

I would like to know if there is a good graphics library for python that will allow me to write a console/terminal application in which I can draw images and or shapes similar to libraries that are available in C++. My applications will be developed for linux primarily but will likely also be made available for windows but it ultimately not necessary.
I already used the following libraries that offer this type of resource:
Tkinter
wxPython (https://www.wxpython.org/) - you can use it to draw shapes or images and there are a lot of built ins resources to create GUI
Pygame (https://www.pygame.org/news) - it's very useful to do physics simulations, you can use built in function to draw circles, blit images into the screen, access keys inputs, etc.
Matplotlib (https://matplotlib.org/) - this is good to mathematical purposes to draw graphs, but you can animate the graphs too
The Pygame help and docs is not user friendly (my think), but the learning curve is fast.

A way to extrude 2d text in The Foundry Nuke via Python

I'd like to know if there's a way to turn Nuke's text (contained in Text node) into polygonal object and then extrude it along Z axis? It's possible in Blackmagic Fusion, it's even possible in Apple Motion 5. Who knows how to do it in Nuke via Python?
logoPlate = nuke.nodes.Text(name="forExtrusion")
logoPlate['font'].setValue("~/Library/Fonts/Cuprum-Bold.ttf")
logoPlate['xjustify'].setValue("center")
logoPlate['yjustify'].setValue("center")
logoPlate['box'].setValue([0,0,512,256])
logoPlate['translate'].setValue([-20, 50])
logoPlate['size'].setValue(48)
logoPlate['message'].setValue("TV Channel logo")
logoPlate.setInput(0,nuke.selectedNode())
I am not interested in using exported obj, fbx or abc from 3D packages or any third party plugins.
The only method to extrude a text at the moment (in NUKE version 10.5) is to trace a text logo with Polygon shape tool using ModelBuilder node.
modelBuilder = nuke.createNode('ModelBuilder')
camera = nuke.createNode('Camera2')
nuke.toNode('ModelBuilder1').setSelected(True)
nuke.toNode('Camera1').setSelected(True)
nuke.connectNodes(2, camera)
nukescripts.connect_selected_to_viewer(0)
n = nuke.toNode('ModelBuilder1')
k = n.knob('shape').setValue(6) #'Polygon' tool in dropdown 'shape' menu
k.execute()
After tracing the logo I used Extrude from ModelBuilder's context menu and then baked out a geometry. But you can use only straight lines due to nature of polygonal modeling in NUKE.
No NURBS geometry.
script = nuke.thisNode()['bakeMenu'].value()
eval(script)
Typically you would use a 3D modelling program like Modo, Maya, Cinema 4D, etc. Create and output your text as a model and import it into Nuke. To create 3D text directly in Nuke, you need the Geometry Tools plugin. Then simply use the PolyText node.
Documentation on PolyText
Download site for Geometry Tools

Using python for graphics projection?

If this is not the best place to ask this, please advise me on an alternative exchange.
I'm trying to create a matrix (N x N) and project it onto a wall using a projector. Each cell of the matrix will have the option to be color-coded or lit. So, given a matrix and a cell, the program will be able to colorize it.
Right now I can achieve this using the graphics.py library and Tkinter. However, when I connect my projector to my laptop via VGA, I have to drag the Tkinter window over and position it on the extended projector screen. It's a manual drag and re-positioning and this should be all automatic.
Are there any other methods (preferably in Python) of achieving this or something similar?
Thanks!
Set your laptop to mirror its screen instead of using the projector as an extended desktop. Then you won't have to drag Tkinter over. This is an OS / videocard setting and has nothing to do with Python.

Tips for interactive machine vision grid

I am working on a program for machine vision. I am trying to do the following:
Grab image at a certain zoom level and find borders.
Take that image and subdivide into a fixed sized grid (which is pre-determined).
Project the image+grid in a UI and allow a user to select/deselect individual grid boxes.
Currently I am using PyQt+Python2.7 with C++ for the computations. I am just wondering if there is a good tutorial for the UI grid section.
Use the Graphics View Framework. Add each grid item as a separate pixmap using scene->addPixmap. Make items selectable using item->setFlag(QGraphicsItem::ItemIsSelectable);. Use scene's selectionChanged signal and scene->selectedItems() to know about selected items.
You can use QPixmap::copy to cut off a rectangle.

Categories