qgissatellite-image

How do QGIS preprocess the image, why they looks so beautiful?


New to the satellite image and found something weird. The satellite image(3 channels only, rgb) open by the rasterio looks like this.

enter image description here

But the image I open by the QGIS(just drag and drop, without setting any parameters) looks like this.

Beautiful image

What are the algorithms behind the scene? Is is possible to use QGIS directly to perform batch processing on the images? And apply "stretch using current extent" on the image.

Thanks


Solution

  • Find out the answer I think, it is just min-max stretching + percentile

    def stretch_to_min_max(img):
        min_percent = 2   # Low percentile
        max_percent = 98  # High percentile
        lo, hi = np.percentile(img, (min_percent, max_percent))
    
        res_img = (img.astype(float) - lo) / (hi-lo)
        
        return np.maximum(np.minimum(res_img*255, 255), 0).astype(np.uint8)
    

    enter image description here

    Figure this out after look at this widget

    enter image description here