图像数据维度属性统计

图像数据维度属性统计



前言

通常,在训练神经网络模型时,需要输入固定尺寸的图像;即使对于可以输入不同尺寸图像的网络,原始图像的维度属性,对于如何将图像转换为特定尺寸输入网络也有一定的指导作用。对原始数据的尺寸分布的了解,有助于后期网络输入的确定


主要为以下2个层面的统计:

一、图像尺寸分布散点图

代码如下:

import os
import numpy as np
from PIL import Image
import matplotlib.pyplot as plt


path = '/home/VDI/sibetit-l06/research/endoscopy/data/WLI/'
heights = []
widths = []
a = []
for i in os.listdir(path):
    g_truth = Image.open(os.path.join(path + i))
    groundTruth = np.asarray(g_truth)  # (height,width,channel)
    height, width, channel = groundTruth.shape
    heights.append(height)
    widths.append(width)

plt.title("scatter diagram")
plt.xlabel("height")
plt.ylabel("width")
plt.plot(heights,widths,'ro')
plt.show()

结果示例:
在这里插入图片描述

二、相同尺寸图像的数量统计

代码如下(示例):

import os
import numpy as np
from PIL import Image
from collections import Counter


path = '/home/VDI/sibetit-l06/research/endoscopy/data/WLI/'
size = []
for i in os.listdir(path):
    g_truth = Image.open(os.path.join(path + i))
    groundTruth = np.asarray(g_truth)  # (height,width,channel)
    height, width, channel = groundTruth.shape
    size.append((height, width))

result = Counter(size)
print(result)

结果示例:

Counter({(576, 768): 126, (576, 720): 49, (1080, 1920): 23, (480, 720): 21, (480, 640): 9, (533, 697): 6})
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值