我想使用切片超像素分割图像,然后用所述超像素的平均颜色替换超像素的原始颜色。
import numpy as np
import matplotlib.pyplot as plt
from skimage import io
from skimage.segmentation import slic, mark_boundaries
from skimage.data import astronaut
from skimage.measure import regionprops
img = astronaut()
segments = slic(img, n_segments=512, compactness=10,
multichannel=True,
enforce_connectivity=True,
convert2lab=True)
regions = regionprops(segments, intensity_image=img)
我得到错误ValueError: Label and intensity image must have thesame shape.
Segments shape is (512,512) 和 img shape in (512,512,3)。regionprops
在我的情况下正确使用什么?