惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Help Net Security
Help Net Security
U
Unit 42
T
Tailwind CSS Blog
Y
Y Combinator Blog
阮一峰的网络日志
阮一峰的网络日志
博客园_首页
云风的 BLOG
云风的 BLOG
博客园 - Franky
D
DataBreaches.Net
Last Week in AI
Last Week in AI
人人都是产品经理
人人都是产品经理
Cisco Talos Blog
Cisco Talos Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Blog — PlanetScale
Blog — PlanetScale
Know Your Adversary
Know Your Adversary
宝玉的分享
宝玉的分享
V
Visual Studio Blog
AWS News Blog
AWS News Blog
NISL@THU
NISL@THU
I
Intezer
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
P
Privacy International News Feed
T
Tor Project blog
S
Securelist
Microsoft Security Blog
Microsoft Security Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Recorded Future
Recorded Future
C
Cisco Blogs
P
Palo Alto Networks Blog
Hacker News: Ask HN
Hacker News: Ask HN
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Recent Commits to openclaw:main
Recent Commits to openclaw:main
月光博客
月光博客
T
Threat Research - Cisco Blogs
N
News and Events Feed by Topic
AI
AI
Cyberwarzone
Cyberwarzone
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
MongoDB | Blog
MongoDB | Blog
Microsoft Azure Blog
Microsoft Azure Blog
Scott Helme
Scott Helme
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Martin Fowler
Martin Fowler
量子位
L
LINUX DO - 热门话题
H
Heimdal Security Blog
GbyAI
GbyAI
P
Privacy & Cybersecurity Law Blog
博客园 - 【当耐特】

博客园 - Sanny.Liu-CV&&ML

GRPO 是否“真的在学” clip的底层原理---深入源码:手把手剖析OpenAI CLIP的实现结构与细节 Decoder-Only、Encoder-Only 与 Encoder-Decoder linux 进程内存占用查看 用PyTorch从零搭建一个Transformer模型 基于树编辑距离的相似度(TEDS) 图片,二进制,base64互转 OCR相关的笔记 opencv的RGB 颜色表 transformers中的generate函数解读 5 levels of text splitting PyMuPDF工具说明 OCR表格识别 uvicorn,一个无敌的 Python 库! stable diffusion中controlnet详细使用方法总结 lora训练参数设置 Dreambooth, Textual Inversion, LoRA, Hypernetworks ,示意图解释 转载:深度学习:蒸馏Distill MoveNet:超快且准确的姿态检测模型 根据5个人脸特征点,快速计算人脸角度
算一个bbox和一个mask区域的重叠
Sanny.Liu-CV&&ML · 2025-11-27 · via 博客园 - Sanny.Liu-CV&&ML
def get_bbox_in_mask_overlap_ratio(bbox, mask):
    """
    判断边界框是否在二值化的 mask 区域内。(二值化为0和255),重叠区域占bbox的比率

    参数:
        bbox: tuple 或 list,表示边界框 (x_min, y_min, x_max, y_max)
        mask: numpy 数组,二值化的图像,值为 1 表示区域内,值为 0 表示区域外

    返回:
        bool: 如果 bbox 完全在 mask 区域内,返回 True;否则返回 False
    """
    x_min, y_min, x_max, y_max = bbox

    # 检查 bbox 的边界是否超出 mask 的范围
    if x_min < 0 or y_min < 0 or x_max > mask.shape[1] or y_max > mask.shape[0]:
        return False

    # 提取 bbox 区域对应的 mask 子区域
    bbox_mask = mask[int(y_min):int(y_max), int(x_min):int(x_max)]

    ## mask fg val is 1
    # 判断 bbox 区域是否完全在 mask 区域内
    #return np.any(bbox_mask == 255)
    bbox_area = (y_max-y_min)*(x_max-x_min)
    ## 获得由多少个重叠的像素
    bin_num = np.sum(bbox_mask == 255)
    ## 计算重叠区域的占比
    ratio = bin_num/(bbox_area+1)

    print('===================',bin_num, bbox_area, bin_num*1.0/bbox_area)
    return ratio