分割後圖像塊合併方法之歸一化合並

我也不知道用中文該怎麼說,反正相關論文叫Normalized cuts and image segmentation
這些都是skimage這個模塊裏面的官網的例子,記錄一下,

from skimage import data, io, segmentation, color, filters
from skimage.future import graph
from matplotlib import pyplot as plt
from skimage.measure import regionprops
from skimage import draw
import numpy as np

img_path = "./sample.jpg"
img = io.imread(img_path)
labels1 = segmentation.slic(img, compactness=30, n_segments=400)
out1 = color.label2rgb(labels1, img, kind='avg')
io.imsave('./3.jpg',out1)
g = graph.rag_mean_color(img, labels1, mode='similarity')
labels2 = graph.cut_normalized(labels1, g)
out2 = color.label2rgb(labels2, img, kind='avg')
io.imsave('./4.jpg',out2)

3.jpg
分割結果
4.jpg
Normalized cut

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章