def get_mapself x1 x2 y1 y2 = 0 8191 0 8191 # selfbig_map40904097+540904097+5=255 while x1 8192 and npsumselfbig_mapx1 == 0 x1 += 1 while y1 8192 and npsumsel
The function get_map() takes no input parameters and returns nothing. It first sets the variables x1, x2, y1, and y2 to 0 and 8191, indicating the boundaries of the map. Then it iterates through the rows and columns of the big_map array to find the edges of the actual map. It does this by incrementing x1 and y1 until it finds a row or column with non-zero values, and it decrements x2 and y2 until it finds a row or column with non-zero values. If the x1 is greater than or equal to x2 or y1 is greater than or equal to y2, it returns nothing.
If it finds the edges of the map, it creates a copy of the sub-array of big_map that includes the map and a 1-pixel border around it. It sets all values in this copy greater than or equal to 100 to 255, indicating an obstacle. It then creates another copy of this array and iterates through each pixel. For each pixel, it checks if any of the neighboring pixels are obstacles. If so, it sets the current pixel to 255 as well. Finally, it sets all values less than 100 to 0. It saves the resulting map as a jpg image with a filename based on the coordinates of the top-left corner of the map, and it saves the same image as the target image with the filename "target.jpg"
原文地址: https://www.cveoy.top/t/topic/fFCb 著作权归作者所有。请勿转载和采集!