Python tool method 39 crop large image to small image | restore small image to large image (including generating pseudo-label for large image)

In the processing of remote sensing images, there are usually large images of tens of thousands x tens of thousands. Small image), test image (prediction needs to be restored to a large image on a small image), and generation of pseudo-labels (requiring pseudo-labels of large images, not small images) all bring difficulties. For this purpose, implement function 1: crop the large image into a small image file, and implement function 2: restore the small image to a large image file.

The core functions here are implemented by https://hpg123.blog.csdn.net/article/details/124824892. You need to save all the code in chapter 1 in the above link as imgutils.py

1. Crop the large picture to a small picture file

The complete code is as follows, you need to modify path (the parent path of the picture), save_dir (the save path of the small picture file), crop_size (the cropping size of the small picture), and pad (the space between the two pictures when cropping the small picture) according to your own needs. overlapping area)

import math,os
from imgutils import *
import numpy as np
from PIL 

Guess you like

Origin blog.csdn.net/a486259/article/details/130438285