当前位置:网站首页>Get the size of the picture
Get the size of the picture
2022-06-12 06:09:00 【Just change your name】
img.shape It can be up to size
because cv2 After reading img yes numpy array,
img.size It refers to the number after multiplying the width and height channels of the picture ,
You need to specify the dimension to get the width and height channel ,
such as ,np.size(img, 0) refer to h Size ,
np.size(img, 1) w
np.size(img, 2) c This dimension applies to color channel read in , Single channel read in will report an error
Return type ,img.shape return tuple, np.size(img, 0) return int Type digital .
If it is torch Type data
img.shape and img.size() The returned content has the same meaning , All are h, w, c.
Return type , All are torch.size, In square brackets index You can take the size of a dimension .
Specially , If img.size(0) This specifies the dimension , return int Number of types , Follow numpy The same as .
import cv2
raw_img_pth = r"F:\vscode_files\project\segment_side\data\raw_img\segment_side\6236a959d839b.jpg"
img = cv2.imread(raw_img_pth, 0) # Single channel read in
print(img.shape) # h, w
import cv2
raw_img_pth = r"F:\vscode_files\project\segment_side\data\raw_img\segment_side\6236a959d839b.jpg"
img = cv2.imread(raw_img_pth, 1) # Color channel read in
print(img.shape) # h, w c
import numpy as np
print(type(img))
print(img.size)
print(np.size(img, 0))
import torch
img = torch.from_numpy(img)
print(img.shape)
print(img.size())
output:
(288, 384)
(288, 384, 3)
<class 'numpy.ndarray'>
331776
288
torch.Size([288, 384, 3])
torch.Size([288, 384, 3])
Read and write the dimensions together :
import cv2
import numpy as np
raw_img_pth = r"F:\vscode_files\project\segment_side\data\raw_img\segment_side\6236a959d839b.jpg"
print(cv2.imread(raw_img_pth, 0).shape) # Single channel read in
output:
(288, 384)
边栏推荐
- Logistic regression model
- Chartextcnn (Ag dataset - news topic classification)
- Leetcode-553. Optimal division
- Script for unity3d to recursively search for a node with a specific name from all child nodes of a node
- 夜神模擬器adb查看log
- EBook upload
- 获取图片的尺寸
- Leetcode 第 80 场双周赛题解
- On the normalization of camera rotation interpolation
- Using hidden Markov model to mark part of speech
猜你喜欢

2D human pose estimation for pose estimation - pifpaf:composite fields for human pose estimation

sqlite交叉編譯動態庫

(UE4 4.27) UE4 adds a customized meshpass to realize the edge illumination of the mobile terminal

相机图像质量概述

cv2.fillPoly coco annotator segment坐标转化为mask图像

Logistic regression model

Word2Vec

First note

MySQL master-slave, 6 minutes to master

Directx11 advanced tutorial PBR (1) summary of physical phenomena of light
随机推荐
Who is more fierce in network acceleration? New king reappeared in CDN field
User login (medium)
Remap function of C different interval mapping
Leetcode-1552. Magnetic force between two balls
Why do I object so [1.01 to the power of 365 and 0.99 to the power of 365]
2D human pose estimation for pose estimation - pifpaf:composite fields for human pose estimation
MySQL 主从,6 分钟带你掌握
单通道图片的读入
Unity implements smooth interpolation
N-degree Bessel curve
Quickly master makefile file writing
UE4 4.27 modify the mobile forward pipeline to support cluster multi light source culling
MySQL notes
Unable to access this account. You may need to update your password or grant the account permission to synchronize to this device. Tencent corporate email
n次贝塞尔曲线
(UE4 4.27) customize globalshader
Pytorch implementation of regression model
sqlite交叉编译动态库
IBL of directx11 advanced tutorial PBR (3)
Leetcode-553. Optimal division