图像分割

  • kdx
    了解作者
  • Python
    开发工具
  • 6.1KB
    文件大小
  • 7z
    文件格式
  • 0
    收藏次数
  • 5 积分
    下载积分
  • 0
    下载次数
  • 2022-06-28 15:50
    上传日期
进行图像分割,利用聚类进行分割,变分法等
ch09.7z
  • ch09
  • .idea
  • dictionaries
  • Administrator.xml
    240B
  • scopes
  • scope_settings.xml
    139B
  • misc.xml
    1.4KB
  • other.xml
    187B
  • workspace.xml
    36.3KB
  • testrunner.xml
    248B
  • .name
    4B
  • encodings.xml
    166B
  • modules.xml
    262B
  • ch09.iml
    286B
  • vcs.xml
    166B
  • ch09_fig91_a-simple- directed -graph.py
    342B
  • ch09_fig94-P199.py
    1002B
  • ch09_fig92还有问题.py
    518B
  • ch09_fig97-P206.py
    609B
  • ch09_fig95-P203.py
    474B
内容介绍
from scipy.misc import imresize from PCV.tools import graphcut from PIL import Image from pylab import * def create_msr_labels(m, lasso=False): """ Create label matrix for training from user annotations. """ labels = zeros(im.shape[:2]) # background labels[m == 0] = -1 labels[m == 64] = -1 # foreground if lasso: labels[m == 255] = 1 else: labels[m == 128] = 1 return labels # load image and annotation map im = array(Image.open('376043.jpg')) m = array(Image.open('376043.bmp')) # resize scale = 0.1 im = imresize(im, scale, interp='bilinear') m = imresize(m, scale, interp='nearest') # create training labels labels = create_msr_labels(m, False) # build graph using annotations g = graphcut.build_bayes_graph(im, labels, kappa=2) # cut graph res = graphcut.cut_graph(g, im.shape[:2]) # remove parts in background res[m == 0] = 1 res[m == 64] = 1 # plot the result figure() imshow(res) gray() xticks([]) yticks([]) savefig('labelplot.pdf')
评论
    相关推荐