高斯除法#

在处理具有膜染色的图像时,有时会发生膜的强度不均匀并在局部发生变化的情况。这种强度变化可能会影响细胞分割算法。在这些情况下,通过将图像除以其高斯模糊版本来均匀化强度可能是有意义的。

import pyclesperanto_prototype as cle
from skimage.io import imread, imshow
from skimage.filters import gaussian

在这张图像中,你可以看到膜的强度从上到下逐渐减弱。

image = imread('../../data/membranes_2d.tif')
cle.asarray(image)
cle._ image
shape(256, 256)
dtypefloat32
size256.0 kB
min547.0
max32145.0

这种强度梯度可以通过将图像除以其背景(即其高斯模糊版本)来消除。

intensity_equivalized = cle.divide_by_gaussian_background(image, sigma_x=10, sigma_y=10)
intensity_equivalized
cle._ image
shape(256, 256)
dtypefloat32
size256.0 kB
min0.32106277
max9.812795

工作原理#

为了展示其工作原理,我们将使用scikit-image和numpy通过两个步骤执行相同的操作。

background = gaussian(image, sigma=10)
imshow(background, cmap="Greys_r")
C:\Users\haase\mambaforge\envs\bio39\lib\site-packages\skimage\io\_plugins\matplotlib_plugin.py:150: UserWarning: Low image data range; displaying image with stretched contrast.
  lo, hi, cmap = _get_display_range(image)
<matplotlib.image.AxesImage at 0x1aa03625160>
../_images/877863f43d14513d9058d0a9ec9c00dd8807c51b7186cf4535b944a5ad9dd17d.png
result = image / background
imshow(result, cmap="Greys_r")
C:\Users\haase\mambaforge\envs\bio39\lib\site-packages\skimage\io\_plugins\matplotlib_plugin.py:150: UserWarning: Float image out of standard range; displaying image with stretched contrast.
  lo, hi, cmap = _get_display_range(image)
<matplotlib.image.AxesImage at 0x1aa0350d580>
../_images/ad34f3291ef39b6d4d71af83fb281fc7f5a7aea0648c2907e7884b0587083afc.png