MCPcopy Create free account
hub / github.com/CVCUDA/CV-CUDA / main

Function main

samples/operators/resize.py:31–56  ·  view source on GitHub ↗

Resize an image with CVCUDA.

()

Source from the content-addressed store, hash-verified

29
30
31def main() -> None:
32 """Resize an image with CVCUDA."""
33 # docs_tag: begin_main
34 args: argparse.Namespace = parse_image_args("cat_resized.jpg")
35 # docs_tag: begin_read_image
36 input_image: cvcuda.Tensor = read_image(args.input)
37 # docs_tag: end_read_image
38
39 # docs_tag: begin_resize
40 # 1. Resize the image to the specified width and height
41 # Since the image gets read as HWC format,
42 # we need to have the same number of dimensions in the output shape
43 # i.e. (height, width, 3)
44 output_image: cvcuda.Tensor = cvcuda.resize(
45 input_image, (args.height, args.width, 3)
46 )
47 write_image(output_image, args.output)
48
49 # 2. If we have a batch dimension, we can still resize the image
50 batched_image: cvcuda.Tensor = input_image.reshape((1, *input_image.shape), "NHWC")
51 batched_output_image: cvcuda.Tensor = cvcuda.resize(
52 batched_image, (1, args.height, args.width, 3)
53 )
54 assert batched_output_image.shape == (1, args.height, args.width, 3)
55 # docs_tag: end_resize
56 # docs_tag: end_main
57
58
59if __name__ == "__main__":

Callers 1

resize.pyFile · 0.70

Calls 5

parse_image_argsFunction · 0.90
read_imageFunction · 0.90
write_imageFunction · 0.90
reshapeMethod · 0.80
resizeMethod · 0.45

Tested by

no test coverage detected