栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

统计可见光图与红外图标准差

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

统计可见光图与红外图标准差

import numpy as np
import os
import cv2
import csv

rgb_path = "L:\Flir\FLIR_ADAS_1_3\FLIR_ADAS_1_3\train\RGB"

rgb_file_name = os.listdir(rgb_path)

print(rgb_file_name)
print(len(rgb_file_name))

vis_stds = []
infrar_stds = []

with open('country1.csv', 'w', newline='') as csvfile:
    writer = csv.writer(csvfile)
    for rfn in rgb_file_name[1:]:
        rfn_path = os.path.join(rgb_path, rfn)
        img_vis = None
        img_infrar = None
        img_rgb = None
        if os.path.exists(rfn_path):
            # print(rfn_path)
            img_rgb = cv2.imread(rfn_path)
            img_vis = cv2.imread(rfn_path, cv2.IMREAD_GRAYSCALE)
        infrar_path = rfn_path.replace("RGB", "thermal_8_bit").replace(".jpg", ".jpeg")
        if os.path.exists(infrar_path):
            # print(infrar_path)
            img_infrar = cv2.imread(infrar_path, cv2.IMREAD_GRAYSCALE)
        if (img_vis is not None) and (img_infrar is not None)and (img_rgb is not None):
            rgb_std = np.std(img_rgb)
            vis_std = np.std(img_vis)
            infrar_std = np.std(img_infrar)
            print("vis std: ", vis_std, "infrar std: ", infrar_std, "rgb std: ", rgb_std)
            vis_stds.append(vis_std)
            infrar_stds.append(infrar_std)
            writer.writerow([vis_std, infrar_std, rgb_std])

        # break

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/350163.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号