Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add utils for plotting flow, and demo of new Baker et al. color scheme #570

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

aviziskind
Copy link

@aviziskind aviziskind commented Nov 30, 2023

Use the test/test_flow_coloring.py script to see a comparison of the new Baker et al. flow color scheme.
It relies on the code for the Baker et al colormap implemented in neurite in this PR: adalca/neurite#78

Use the functions in scripts/py/flow_utils.py to convert the flow output by a transformer to the format that can be plotted with the new color scheme (tested with both PyTorch and Tensorflow)

The figures below are produced by the included test_flow_coloring.py script.

Figure_1
Figure 1: Direct comparison of 'Baker et al.' color scheme and 'winter' colormap:
Some advantages of the Baker et al. color scheme are:
(a) Each direction is a distinctive color (instead of a range from blue-to-green).
(b) The color wheel is cyclic/circularly continuous as a function of direction angle (whereas there is a sharp blue/green discontinuity in the winter colormap)
(c) The 'lightness' of the color increases as the magnitude of the flow decreases, so that zero flow is white, which makes it easier to distinguish where the magnitude of the flow field is high or low.

Figure_2
Figure 2: Example simple flow fields plotted using the Baker et al color scheme.
On the left column: The Flow colorwheel for this figure as an RGB image (top), as an arrow field (middle), and a test "image" -- a rectangle of 1's surrounded by 0's (bottom). Each column after this demonstrates shows a simple, spatially varying flow field, either visualized as an RGB image (top), or as an arrow field (middle). The arrow field is more straightforward to understand for smaller images like these, but becomes harder for much larger images/flow fields, where individual arrows may be hard to make out, and for which the RGB image becomes more suitable. In the RGB image, the colors at each pixel are just the color of the arrow at the corresponding location. On the bottom of each column is the output of the SpatialTransformer when applied to the test "source" image (bottom left corner) using the flow field from this column.

Figure_3
Figure 3: Example simple flow fields plotted using the Winter et al color scheme. Same as Figure 2, but using the winter colormap. The advantages of the new Baker et al. color scheme are apparent by comparing Figures 2 and 3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant