Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use cv2.resize (img, (w, h))

2025-01-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "how to use cv2.resize (img, (w, h))". In daily operation, I believe many people have doubts about how to use cv2.resize (img, (w, h)). The editor has consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about how to use cv2.resize (img, (w, h)). Next, please follow the editor to study!

Pay attention to the details: after reading the picture using cv2.imread (), the shape and dimensional layout of the data is (HMagneWforce C), but when zooming using the function cv2.resize (), the target shape passed in is (WMague H), not (HMagee W), which should be paid special attention to.

The code experiment shows:

Import numpy as npimport cv2 # Import opencv module image_0 = cv2.imread ("bryant.jpg") # read the picture to be processed cv2.imshow ("Original Image", image_0) print ('type of image_0 variable is:', type (image_0), 'the shape of the image is:', image_0.shape) cv2.waitKey (0) # do not let the program end suddenly image_1 = cv2.resize (image_0, 1000) cv2.imshow ("Image-1", image_1) print (the type of 'image_1 variable is:', type (image_1), 'the shape of the image (HQ WJ C) is:', image_1.shape) cv2.waitKey (0) # does not let the program end abruptly

Console output result:

Copyright (C) Windows PowerShell Microsoft Corporation. All rights reserved. It took 824ms to try a new cross-platform PowerShell https://aka.ms/pscore6 to load personal and system profiles. (base) PS C:\ Users\ chenxuqi\ Desktop\ News4cxq\ test4cxq > conda activate ssd4pytorch2_2_0 (ssd4pytorch2_2_0) PS C:\ Users\ chenxuqi\ Desktop\ News4cxq\ test4cxq > &'D:\ Anaconda3\ envs\ ssd4pytorch2_2_0\ python.exe''c:\ Users\ chenxuqi\ .vscode\ extensions\ ms-python.python-2021.1.502429796\ lib\ python\ debugpy\ launcher' '53732' -'c:\ Users\ chenxuqi\ Desktop\ The type of News4cxq\ test4cxq\ testCV_1.py'image_0 variable is: the shape of the image (H Image_1 C) is: (667,667,3) the type of image_1 variable is: the shape of the image. (1000, 1000, 3) (ssd4pytorch2_2_0) PS C:\ Users\ chenxuqi\ Desktop\ News4cxq\ test4cxq >

Screenshot of the running result:

At this point, the study on "how to use cv2.resize (img, (w, h))" is over. I hope I can solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report