Commit 2480c2de by Emmanuel Roubin

### Geodesic reconstruction example

parent ca79acc5
Pipeline #64741 passed with stages
in 26 minutes and 2 seconds
 ... ... @@ -8,6 +8,7 @@ This example shows how to use the geodesic reconstruction # sphinx_gallery_thumbnail_number = 1 import matplotlib.pyplot as plt import matplotlib as mpl import numpy import spam.excursions import spam.filters ... ... @@ -16,9 +17,9 @@ import spam.filters # Generate a morphology ############################################ # Generation and excrusion of a realisation of a correlated random field covariance = {'type': 'stable', 'alpha': 2.0, 'correlation_length': 0.01} covariance = {'type': 'stable', 'alpha': 2.0, 'correlation_length': 0.005} realisation = spam.excursions.simulateRandomField(nNodes=500, covariance=covariance, nRea=1, dim=2, vtkFile="morpho") excursion = realisation > 0.1 excursion = realisation > 0.05 ############################################ # Geodesic reconstruction ... ... @@ -38,17 +39,15 @@ recC = spam.filters.binaryGeodesicReconstruction(excursion, marker) ###################### # Plots fig, axs = plt.subplots(2, 2) plt.setp(axs, xticks=[], yticks=[]) axs[0, 0].imshow(excursion) axs[0, 1].imshow(recA) axs[1, 0].imshow(recB) axs[1, 1].imshow(recC) axs[0, 0].set_title("Morphology") axs[0, 1].set_title("Geodesic reconstruction from a square in the center") axs[1, 0].set_title("Geodesic reconstruction from the top side") axs[1, 1].set_title("Geodesic reconstruction from the left and bottom side") plot_image = numpy.zeros(excursion.shape, dtype=int) plot_image[numpy.where(excursion)] = -1 # set 1 for morpho plot_image[numpy.where(recA)] = -2 # set 2 for center plot_image[numpy.where(recB)] = 1 # set 3 for top plot_image[numpy.where(recC)] = 2 # set 4 for left bottom plt.figure() plt.imshow(plot_image, cmap='coolwarm') plt.axis('off') plt.show() ... ...
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!