如何在(CIE)LAB格式的图像上应用高斯模糊?RGB可以用rgb_blurred = skimage.filters.gaussian(lab)进行模糊处理,但这在实验室是行不通的(因为它有第一个通道)。有没有一种方法可以模糊图像,而不是先将它们转换回rgb,然后再将它们转换回来?
发布于 2019-10-07 00:05:54
从docs
多维滤波器被实现为一维卷积滤波器的序列。
因此,您也可以将该滤镜应用于Lab图像。图像存储为numpy数组,因此如果您只想将过滤器应用于某些通道,则使用标准numpy索引是没有问题的。事实上,模糊a和b通道对视觉印象的影响很小。效果来自模糊L通道:
from skimage import data
from skimage.filters import gaussian
from skimage.color import rgb2lab, lab2rgb
import matplotlib.pyplot as plt
img = data.astronaut()
lab = rgb2lab(img)
blurred = gaussian(lab, 5)
lab[:,:,0] = gaussian(lab[:,:,0], 5, preserve_range=True)
fig, ax = plt.subplots(1,3,figsize=(20,20))
ax[0].imshow(img)
ax[1].imshow(lab2rgb(blurred))
ax[2].imshow(lab2rgb(lab))
ax[0].set_title('Original')
ax[1].set_title('Blurred (entire image)')
ax[2].set_title('Blurred (L channel only)')

需要注意的是,在对单个通道应用滤镜时,必须将参数preserve_range设置为True,否则结果会在0.0到1.0的范围内。
https://stackoverflow.com/questions/58251629
复制相似问题