python图像分割代码_Python 马尔科夫图像分割代码

这段Python代码演示了如何使用马尔科夫过程进行图像分割。通过滤波器和像素邻域交互,不断迭代更新像素标签,最终得到分割结果并保存为bmp文件。
摘要由CSDN通过智能技术生成

# -*- coding: utf-8 -*-

"""

Created on Wed Jun  6 13:38:42 2018

@author: Administrator

"""

import cv2

import numpy as np

import scipy.signal

img = cv2.imread('img_roi_4.bmp', 0)

img_double = np.array(img, dtype = np.float64)

cluster_num = 2

max_iter = 200

label  = np.random.randint(1, cluster_num + 1, size = img_double.shape)

#label = 2 * np.ones((70, 70))

iter  = 0

f_u = np.array([0,1,0,0,0,0,0,0,0]).reshape(3, 3)

f_d = np.array([0,0,0,0,0,0,0,1,0]).reshape(3, 3)

f_l = np.array([0,0,0,1,0,0,0,0,0]).reshape(3, 3)

f_r = np.array([0,0,0,0,0,1,0,0,0]).reshape(3, 3)

f_ul = np.array([1,0,0,0,0,0,0,0,0]).reshape(3, 3)

f_ur = np.array([0,0,1,0,0,0,0,0,0]).reshape(3, 3)

f_dl

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值