How to use the porespy.filters function in porespy

To help you get started, we’ve selected a few porespy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github PMEAL / porespy / test / unit / test_filters.py View on Github external
def test_apply_chords_axis0(self):
        c = ps.filters.apply_chords(im=self.im, spacing=3, axis=0)
        assert c.sum() == 23722
        c = ps.filters.apply_chords(im=self.im, axis=0)
        assert c.sum() == 102724
github PMEAL / porespy / test / unit / test_filters.py View on Github external
def test_apply_chords_without_trimming(self):
        c = ps.filters.apply_chords(im=self.im, trim_edges=False)
        assert c.sum() == 125043
        c = ps.filters.apply_chords(im=self.im, spacing=3, trim_edges=False)
        assert c.sum() == 31215
github PMEAL / porespy / test / unit / test_metrics.py View on Github external
def test_chord_counts(self):
        im = sp.ones([100, 50])
        crds = ps.filters.apply_chords(im, spacing=1, trim_edges=False)
        c = ps.metrics.chord_counts(crds)
        assert sp.all(c == 100)
        crds = ps.filters.apply_chords(im, spacing=1, trim_edges=False, axis=1)
        c = ps.metrics.chord_counts(crds)
        assert sp.all(c == 50)
github PMEAL / porespy / test / unit / test_network_extraction.py View on Github external
np.random.seed(1)
        im3 = ps.generators.blobs([1, 100, 100])
        np.random.seed(1)
        snow_out1 = ps.filters.snow_partitioning(im1, return_all=True)
        pore_map1 = snow_out1.im * snow_out1.regions
        net1 = ps.networks.regions_to_network(im=pore_map1,
                                              dt=snow_out1.dt,
                                              voxel_size=1)
        np.random.seed(1)
        snow_out2 = ps.filters.snow_partitioning(im2, return_all=True)
        pore_map2 = snow_out2.im * snow_out2.regions
        net2 = ps.networks.regions_to_network(im=pore_map2,
                                              dt=snow_out2.dt,
                                              voxel_size=1)
        np.random.seed(1)
        snow_out3 = ps.filters.snow_partitioning(im3, return_all=True)
        pore_map3 = snow_out3.im * snow_out3.regions
        net3 = ps.networks.regions_to_network(im=pore_map3,
                                              dt=snow_out3.dt,
                                              voxel_size=1)
        assert np.allclose(net1['pore.coords'][:, 0],
                           net2['pore.coords'][:, 0])
        assert np.allclose(net1['pore.coords'][:, 1],
                           net2['pore.coords'][:, 2])
        assert np.allclose(net1['pore.coords'][:, 0],
                           net3['pore.coords'][:, 1])
github PMEAL / porespy / test / unit / test_network_extraction.py View on Github external
def setup_class(self):
        self.im = ps.generators.blobs(shape=[300, 300])
        self.snow = ps.filters.snow_partitioning(self.im, return_all=True)
        self.im3d = ps.generators.blobs(shape=[50, 50, 50])
        self.snow3d = ps.filters.snow_partitioning(self.im3d, return_all=True)
github PMEAL / porespy / test / unit / test_metrics.py View on Github external
def test_linear_density(self):
        im = ps.filters.distance_transform_lin(self.im2D, axis=0, mode='both')
        ps.metrics.linear_density(im)
github PMEAL / porespy / examples.py View on Github external
import porespy as ps
import matplotlib.pyplot as plt

# Generate an image of spheres using the imgen class
im = ps.generators.blobs(shape=[500, 500], porosity=0.7, blobiness=1)
plt.figure(1)
plt.imshow(im)

# Chord length distributions
chords = ps.filters.apply_chords(im=im, trim_edges=False)
colored_chords = ps.filters.region_size(chords)
h = ps.metrics.chord_length_distribution(chords, bins=25)
ps.visualization.set_mpl_style()
plt.figure(2)
plt.subplot(2, 2, 1)
plt.imshow(im)
plt.subplot(2, 2, 3)
plt.imshow(chords)
plt.subplot(2, 2, 4)
plt.imshow(colored_chords, cmap=plt.cm.jet)
plt.subplot(2, 2, 2)
plt.bar(h.L, h.pdf, width=h.bin_widths, edgecolor='k')
github PMEAL / porespy / examples.py View on Github external
import porespy as ps
import matplotlib.pyplot as plt

# Generate an image of spheres using the imgen class
im = ps.generators.blobs(shape=[500, 500], porosity=0.7, blobiness=1)
plt.figure(1)
plt.imshow(im)

# Chord length distributions
chords = ps.filters.apply_chords(im=im, trim_edges=False)
colored_chords = ps.filters.region_size(chords)
h = ps.metrics.chord_length_distribution(chords, bins=25)
ps.visualization.set_mpl_style()
plt.figure(2)
plt.subplot(2, 2, 1)
plt.imshow(im)
plt.subplot(2, 2, 3)
plt.imshow(chords)
plt.subplot(2, 2, 4)
plt.imshow(colored_chords, cmap=plt.cm.jet)
plt.subplot(2, 2, 2)
plt.bar(h.L, h.pdf, width=h.bin_widths, edgecolor='k')