当前位置: 首页 > news >正文

漯河市源汇区网站建设东莞网站设计百年

漯河市源汇区网站建设,东莞网站设计百年,wordpress模板插件,天元建设集团有限公司第八建筑图像分割是计算机视觉中的重要任务,用于将图像中的不同区域分割成具有语义意义的区域。以下是几种常用的图像分割评价指标以及它们的代码实现示例(使用Python和常见的计算机视觉库): 1. IoU (Intersection over Union) 与目标检…

图像分割是计算机视觉中的重要任务,用于将图像中的不同区域分割成具有语义意义的区域。以下是几种常用的图像分割评价指标以及它们的代码实现示例(使用Python和常见的计算机视觉库):

1. IoU (Intersection over Union)

与目标检测中的IoU类似,用于衡量预测分割区域与真实分割区域之间的重叠程度。

def calculate_iou(mask_true, mask_pred):intersection = np.logical_and(mask_true, mask_pred)union = np.logical_or(mask_true, mask_pred)iou = np.sum(intersection) / np.sum(union)return iou#e.g.import cv2
import numpy as npmask_true=cv2.imread("round_meter_421.png",0)
mask_pred=cv2.imread("round_meter_423.png",0)mask_true=cv2.resize(mask_true,(512,512),interpolation = cv2.INTER_LINEAR)
mask_pred=cv2.resize(mask_pred,(512,512),interpolation = cv2.INTER_LINEAR)
def calculate_iou(mask_true, mask_pred):intersection = np.logical_and(mask_true, mask_pred)union = np.logical_or(mask_true, mask_pred)iou = np.sum(intersection) / np.sum(union)return iouprint(calculate_iou(mask_true,mask_pred))
#结果0.6660

2. Dice Coefficient

用于衡量预测分割区域与真实分割区域的重叠程度。

def calculate_dice_coefficient(mask_true, mask_pred):intersection = np.logical_and(mask_true, mask_pred)dice_coeff = (2.0 * np.sum(intersection)) / (np.sum(mask_true) + np.sum(mask_pred))return dice_coeff#e.g.import cv2
import numpy as npmask_true=cv2.imread("round_meter_421.png",0)
mask_pred=cv2.imread("round_meter_423.png",0)mask_true=cv2.resize(mask_true,(512,512),interpolation = cv2.INTER_LINEAR)
mask_true = np.where(mask_true != 0, 1, mask_true)
mask_pred=cv2.resize(mask_pred,(512,512),interpolation = cv2.INTER_LINEAR)
mask_pred = np.where(mask_pred != 0, 1, mask_pred)
def calculate_dice_coefficient(mask_true, mask_pred):intersection = np.logical_and(mask_true, mask_pred)dice_coeff = (2.0 * np.sum(intersection)) / (np.sum(mask_true) + np.sum(mask_pred))return dice_coeffprint(calculate_dice_coefficient(mask_true,mask_pred))
#结果是 0.7995

3. Pixel Accuracy:

计算正确预测的像素数量占总像素数量的比例。

def calculate_pixel_accuracy(mask_true, mask_pred):correct_pixels = np.sum(mask_true == mask_pred)total_pixels = mask_true.sizepixel_accuracy = correct_pixels / total_pixelsreturn pixel_accuracy#e.g.import cv2
import numpy as npmask_true=cv2.imread("round_meter_421.png",0)
mask_pred=cv2.imread("round_meter_423.png",0)mask_true=cv2.resize(mask_true,(512,512),interpolation = cv2.INTER_LINEAR)
mask_true = np.where(mask_true != 0, 1, mask_true)
mask_pred=cv2.resize(mask_pred,(512,512),interpolation = cv2.INTER_LINEAR)
mask_pred = np.where(mask_pred != 0, 1, mask_pred)
def calculate_pixel_accuracy(mask_true, mask_pred):correct_pixels = np.sum(mask_true == mask_pred)total_pixels = mask_true.sizepixel_accuracy = correct_pixels / total_pixelsreturn pixel_accuracyprint(calculate_pixel_accuracy(mask_true,mask_pred))
#结果是 0.9914

4. Mean Intersection over Union (mIoU)

计算在不同类别上的平均IoU值。

def calculate_miou(class_iou_list):return np.mean(class_iou_list)

5. Boundary F1-score:

用于衡量分割区域的边界的预测质量。

def calculate_boundary_f1(mask_true, mask_pred):# Calculate true positive, false positive, and false negative boundary pixelstrue_positive = np.sum(np.logical_and(mask_true, mask_pred))false_positive = np.sum(np.logical_and(np.logical_not(mask_true), mask_pred))false_negative = np.sum(np.logical_and(mask_true, np.logical_not(mask_pred)))precision = true_positive / (true_positive + false_positive)recall = true_positive / (true_positive + false_negative)f1_score = 2 * (precision * recall) / (precision + recall)return f1_score#e.g.import cv2
import numpy as npmask_true=cv2.imread("round_meter_421.png",0)
mask_pred=cv2.imread("round_meter_423.png",0)mask_true=cv2.resize(mask_true,(512,512),interpolation = cv2.INTER_LINEAR)
mask_true = np.where(mask_true != 0, 1, mask_true)
mask_pred=cv2.resize(mask_pred,(512,512),interpolation = cv2.INTER_LINEAR)
mask_pred = np.where(mask_pred != 0, 1, mask_pred)
def calculate_boundary_f1(mask_true, mask_pred):# Calculate true positive, false positive, and false negative boundary pixelstrue_positive = np.sum(np.logical_and(mask_true, mask_pred))false_positive = np.sum(np.logical_and(np.logical_not(mask_true), mask_pred))false_negative = np.sum(np.logical_and(mask_true, np.logical_not(mask_pred)))precision = true_positive / (true_positive + false_positive)recall = true_positive / (true_positive + false_negative)f1_score = 2 * (precision * recall) / (precision + recall)return f1_scoreprint(calculate_boundary_f1(mask_true,mask_pred))
#结果是 0.7995

这些代码示例提供了基本的评价指标计算方法,实际应用中可能会涉及更多的细节和优化。使用深度学习框架(如TensorFlow、PyTorch)和计算机视觉库(如OpenCV、Scikit-image)可以更方便地计算这些评价指标,因为它们提供了丰富的内置函数和工具来处理图像分割任务。

http://www.yayakq.cn/news/150898/

相关文章:

  • 高清做 视频在线观看网站wordpress设置静态页
  • 企业建网站多少钱网上购物商城源代码
  • 西宁商城网站建设公司今天新闻事件
  • 郑州企业型网站建设成都专业网站排名推广
  • 做盗链网站网站建设包括内容
  • 天津团购鲜花的网站建设简单产品设计方案模板
  • 专业的做网站软件威海市文登区城乡建设局网站
  • 后端开发网站做一些什么wordpress表excel插件
  • 泰州网站建设费用做网站一定要自己搭建服务器吗
  • 网站建设中企动力公司旅游网站建设方案2019
  • wordpress 微博主题 twitter主题整站seo运营
  • 怎么免费做网站郑州优化网站收费标准
  • 亚马逊虚拟主机做网站上海企业地址大全
  • 建筑中级职称查询网站网站建设收费标准方案
  • 做搜狗手机网站排济南 网站建设 域名注册
  • 网站流量如何转化为钱app快速开发平台
  • 网站建设与管理aspo2o的典型电子商务平台
  • 网站建设和服务器运营织梦做中英文网站详细步骤
  • 建设银行网站上交医保微信企业网站源码下载
  • 织梦做的网站怎样网站开发的进度控制计划表
  • 网站客户端开发创建公司网站 教程
  • 怎么做提高网站排名seo网站推广优化
  • 网站模板没有html文件下载黄金网站app免费视频下载
  • 网站制作验收单百度做广告多少钱一天
  • 文化推广网站建设心得做网站二级页面的
  • 企业名录搜索软件 2022有实力的网站排名优化软件
  • 做直播网站需要学什么软件有哪些哈尔滨网站基础优化
  • 人像摄影网站十大排名湖南十大软件公司介绍
  • 南方科技大学网站建设seo推广原理
  • 太原网站建设的公司排名上不了建设银行网站