This visualization was created to address a request for better visualization of the effects of blurring (smoothing). The (petri dish) image used and the exact context of the discussion can be recovered from the corresponding Carpentries' lesson and related discussion:
import imageio.v3 as iio
import skimage.color
image = iio.imread('data/colonies-01.tif')
image_gray = skimage.color.rgb2gray(image)
fig,ax = plt.subplots()
ax.imshow(image_gray, cmap='gray')
from skimage.util import img_as_ubyte
size = min(image_gray.shape)
x = np.arange(0, size)
y = np.arange(0, size)
X,Y = np.meshgrid(x,y)
img = image_gray[:size,:size]
img = img_as_ubyte(img)
fig = plt.figure()
ax = fig.add_subplot(projection='3d')
surf = ax.plot_surface(X,Y,img, cmap='viridis')
ax.view_init(elev=215, azim=-60)
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('L')
from skimage.util import img_as_ubyte
from skimage.filters import gaussian
image_blur = gaussian(image_gray, sigma=3)
size = min(image_blur.shape)
x = np.arange(0, size)
y = np.arange(0, size)
X,Y = np.meshgrid(x,y)
img = image_blur[:size,:size]
img = img_as_ubyte(img)
fig = plt.figure()
ax = fig.add_subplot(projection='3d')
surf = ax.plot_surface(X,Y,img, cmap='viridis')
ax.view_init(elev=215, azim=-60)
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('L')