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

网站建设公司968seo全国最好的公司

网站建设公司968,seo全国最好的公司,宜兴网站策划,莱芜企业网站建设公司图像分割是计算机视觉中的重要任务,用于将图像中的不同区域分割成具有语义意义的区域。以下是几种常用的图像分割评价指标以及它们的代码实现示例(使用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.khdw.cn/news/5749.html

相关文章:

  • 体验做黑客的网站今天的特大新闻有哪些
  • 电商类网站建设需要多少钱域名申请的流程
  • 深圳高端网站制作公司成都网站建设技术外包
  • 北京网站开发哪家专业提高网站排名
  • 网站空间需要续费百度一下 你就知道官网
  • 一级建造师报考条件2022考试时间有必要买优化大师会员吗
  • python网站搭建长沙seo运营
  • 电子商务网站建设步骤搜索引擎算法
  • 网站建设与管理介绍西安百度竞价推广
  • 漯河做网站的公司网站cms
  • 做的网站如何全屏微信附近人推广引流
  • 什么是新零售网站seo综合查询
  • 南宁市网站开发建设网站开发与设计
  • 英文营销网站建设百度关键词排名联系方式
  • 建设工程教育网手机版站长工具的使用seo综合查询运营
  • 政府网站建设不合格爱站网长尾关键词挖掘工具电脑版
  • 程序员自己做网站怎么赚钱百度app推广
  • 网站seo优化分析报告广州新闻头条最新消息
  • 做网站备案的公司seo整站优化哪家好
  • 北京市城市建设委员会门户网站网页设计主要做什么
  • 做简历用哪个网站西地那非
  • 建手机网站一年费用广州网站制作实力乐云seo
  • 温州哪里可以做企业网站谷歌搜索引擎官网
  • 个人做视频网站网址制作
  • 怎么给网站做链接如何做网站关键词优化
  • psd数据网站网络推广方案书模板
  • 烟台网站排名seo百度关键词首页排名怎么上
  • 雪域什么网站是做电影的北京seo优化多少钱
  • 集团网站建设服务百度seo优化系统
  • 网络营销策划步骤有哪些杭州seo中心