trim_floating_solid

Import packages

[1]:
import numpy as np
import porespy as ps
import scipy.ndimage as spim
import scipy
import matplotlib.pyplot as plt
import skimage
ps.visualization.set_mpl_style()

Create image and variables

[2]:
im2d = ps.generators.blobs(shape=[500, 500])
[3]:
dist = scipy.stats.norm(loc=20, scale=10)
im3d = ps.generators.blobs([100,100,100])
[4]:
fig, ax = plt.subplots(figsize=[7,7]);
ax.imshow(im2d);
ax.axis(False)
plt.title('2D')


fig, ax = plt.subplots(figsize=[7,7]);
ps.visualization.imshow(im3d)
plt.axis(False)
plt.title('3D')

#default values:
conn = None
../../../_images/examples_filters_howtos_trim_floating_solid_6_0.png
../../../_images/examples_filters_howtos_trim_floating_solid_6_1.png

Apply filter function

2D

Conn options are 4 or 8 for 2D images.

[5]:
x = ps.filters.trim_floating_solid(im=im2d, conn=conn)
xx = ps.filters.trim_floating_solid(im=im2d, conn=4)

fig, ax = plt.subplots(figsize=[7,7]);
ax.imshow(x);
ax.axis(False)
plt.title('conn = None')


fig, ax = plt.subplots(figsize=[7,7]);
ax.imshow(xx)
plt.axis(False)
plt.title('conn = 4');
../../../_images/examples_filters_howtos_trim_floating_solid_9_0.png
../../../_images/examples_filters_howtos_trim_floating_solid_9_1.png

3D

Conn options are 6 and 26 for 3D options.

[6]:
x = ps.filters.trim_floating_solid(im=im3d, conn=conn)
xx = ps.filters.trim_floating_solid(im=im3d, conn=6)

fig, ax = plt.subplots(figsize=[7,7]);
ps.visualization.imshow(x);
plt.axis(False)
plt.title('conn = None')


fig, ax = plt.subplots(figsize=[7,7]);
ps.visualization.imshow(xx)
plt.axis(False)
plt.title('conn = 6');
../../../_images/examples_filters_howtos_trim_floating_solid_11_0.png
../../../_images/examples_filters_howtos_trim_floating_solid_11_1.png