Huawei HCIP - AI EI Developer V2.5 Exam H13-321_V2.5 Question # 3 Topic 1 Discussion
H13-321_V2.5 Exam Topic 1 Question 3 Discussion:
Question #: 3
Topic #: 1
If OpenCV is used to read an image and save it to variable "img" during image preprocessing, (h, w) = img.shape[:2] can be used to obtain the image size.
In OpenCV, an image read into a variable such as img is represented as a NumPy array. The .shape attribute returns the dimensions in the format (height, width, channels). Using img.shape[:2] slices the first two elements, giving the height (h) and width (w). This method is a standard practice for quickly retrieving image dimensions in preprocessing workflows.
Exact Extract from HCIP-AI EI Developer V2.5:
"OpenCV stores images as NumPy arrays. The shape property returns (height, width, channels). Accessing shape[:2] returns the image height and width."
[Reference:HCIP-AI EI Developer V2.5 Official Study Guide – Chapter: Image Reading and Writing with OpenCV, ]
Contribute your Thoughts:
Chosen Answer:
This is a voting comment (?). You can switch to a simple comment. It is better to Upvote an existing comment if you don't have anything to add.
Submit