计算两张图片的IOU

编程入门 行业动态 更新时间:2024-10-08 18:40:15

计算<a href=https://www.elefans.com/category/jswz/34/1761627.html style=两张图片的IOU"/>

计算两张图片的IOU

import cv2
import os
import numpy as np
from pathlib import Path
import time
from PIL import Image
import numpy as np#Read images
img1 = np.array(Image.open(032439.413.jpg"))#标注图
img2 = np.array(Image.open(32439.413.png"))#pytorch图片
#print(img1.shape)
#print(img2.shape)#convert unit8 to int numbers, then subtract, then 2D to 1D array
#subArr = np.subtract(img1[:, :, 0].tolist(), img2.tolist()).flatten()intersection = np.sum(np.logical_and(img1, img2[:, :, 0]))
union = np.sum(np.logical_or(img1, img2[:, :, 0]))#Intersection over Union
iou_score = intersection / unionprint(iou_score)

报错:


Img1 should be the .jpg file that has 3 channels

If your image is 2D, just delete one of the ,: from the code

Or just delete the [:,:,0]

If it's 2D, just img1, if it's 3D img1[:, :, 0]

更多推荐

计算两张图片的IOU

本文发布于:2024-03-23 21:50:09,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1743239.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:两张   图片   IOU

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!