for h in rangemax_x for w in rangemax_y crop_img_arr = imgh strideh stride + heightw stridew stride + width #printcrop_img_arrshape crop_mask_ar
The code above is a nested loop that crops the input image, mask, and label arrays into smaller sub-images using a sliding window approach. The sub-images are saved as separate image files with unique names.
The outer loop iterates over the height of the input image using the max_x variable, and the inner loop iterates over the width of the image using the max_y variable. The stride variable determines the step size of the sliding window.
At each iteration, the code extracts a sub-image from the input image, mask, and label arrays using slicing. The sub-images are then converted into Image objects using Image.fromarray(). The img_name, mask_name, and label_name variables are used to construct unique file names for each sub-image.
Finally, the sub-images are saved using the save() method of the Image class, and the i variable is incremented to keep track of the number of sub-images.
原文地址: https://www.cveoy.top/t/topic/bZXH 著作权归作者所有。请勿转载和采集!