当前位置:网站首页>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)
边栏推荐
- 交叉编译libev
- (UE4 4.27) add globalshder to the plug-in
- Book classification based on Naive Bayes
- Leetcode-553. Optimal division
- Database Experiment 3: data query
- Project progress on February 28, 2022
- UE4 4.27 modify the mobile forward pipeline to support cluster multi light source culling
- Directx11 advanced tutorial cluster based deffered shading
- Es6-es11 learning
- Leetcode-1552. Magnetic force between two balls
猜你喜欢
随机推荐
[untitled]
Leetcode 第 80 场双周赛题解
E-book analysis
MySQL 主从,6 分钟带你掌握
Leetcode-1663. Minimum string with given value
交叉编译libev
JS变量作用域
Database experiment I: data definition experiment guide
Storing texture2d to hard disk JPG file with script under unity3d
Database Experiment 2: data update
User login [next]
Types, functions and applications of intelligent sensors
Leetcode-1043. Separate arrays for maximum sum
MNIST handwritten data recognition by CNN
Login authentication filter
Une explication du 80e match bihebdomadaire de leetcode
Logistic regression model
RMB classification II
468. verifying the IP address
In unity3d, billboard effect can be realized towards another target









