<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12
      行走的蓑衣客

      導航

       

       

      """
      將16位遙感圖像壓縮至8位,并保持色彩一致
      """
      from osgeo import gdal
      import os
      import glob
      import numpy as np
      import matplotlib.pyplot as plt # plt 用于顯示圖片
      import matplotlib.image as mpimg # mpimg 用于讀取圖片
      
      
      def read_tiff(input_file):
          """
          讀取影像
          :param input_file:輸入影像
          :return:波段數據,仿射變換參數,投影信息、行數、列數、波段數
          """
          print("**********",input_file)
      
      
          dataset = gdal.Open(input_file)
          rows = dataset.RasterYSize
          cols = dataset.RasterXSize
      
          geo = dataset.GetGeoTransform()
          proj = dataset.GetProjection()
      
          couts = dataset.RasterCount
      
          array_data = np.zeros((couts, rows, cols))
      
          for i in range(couts):
              band = dataset.GetRasterBand(i + 1)
              array_data[i, :, :] = band.ReadAsArray()
      
          return array_data, geo, proj, rows, cols, 1
      
      
      def compress(origin_16, output_8):
          array_data, geo, proj, rows, cols, couts = read_tiff(origin_16)
      
          compress_data = np.zeros((couts, rows, cols))
      
          for i in range(couts):
              band_max = np.max(array_data[i, :, :])
              band_min = np.min(array_data[i, :, :])
      
              cutmin, cutmax = cumulativehistogram(array_data[i, :, :], rows, cols, band_min, band_max)
      
              compress_scale = (cutmax - cutmin) / 255
      
              for j in range(rows):
                  for k in range(cols):
                      if (array_data[i, j, k] < cutmin):
                          array_data[i, j, k] = cutmin
      
                      if (array_data[i, j, k] > cutmax):
                          array_data[i, j, k] = cutmax
      
                      compress_data[i, j, k] = (array_data[i, j, k] - cutmin) / compress_scale
      
          write_tiff(output_8, compress_data, rows, cols, couts, geo, proj)
      
      
      def write_tiff(output_file, array_data, rows, cols, counts, geo, proj):
          Driver = gdal.GetDriverByName("Gtiff")
          dataset = Driver.Create(output_file, cols, rows, counts, gdal.GDT_Byte)
      
          dataset.SetGeoTransform(geo)
          dataset.SetProjection(proj)
      
          for i in range(counts):
              band = dataset.GetRasterBand(i + 1)
              band.WriteArray(array_data[i, :, :])
      
      
      def cumulativehistogram(array_data, rows, cols, band_min, band_max):
          """
          累計直方圖統計
          """
      
          # 逐波段統計最值
      
          gray_level = int(band_max - band_min + 1)
          gray_array = np.zeros(gray_level)
      
          counts = 0
          for row in range(rows):
              for col in range(cols):
                  gray_array[int(array_data[row, col] - band_min)] += 1
                  counts += 1
      
          count_percent2 = counts * 0.02
          count_percent98 = counts * 0.98
      
          cutmax = 0
          cutmin = 0
      
          for i in range(1, gray_level):
              gray_array[i] += gray_array[i - 1]
              if (gray_array[i] >= count_percent2 and gray_array[i - 1] <= count_percent2):
                  cutmin = i + band_min
      
              if (gray_array[i] >= count_percent98 and gray_array[i - 1] <= count_percent98):
                  cutmax = i + band_min
      
          return cutmin, cutmax
      
      
      if __name__ == '__main__':
          input_path = r"D:\test"
      
          classs = os.listdir(input_path)
          i=0
          for folder in classs:
              folderall = os.path.join(input_path, folder)
              # print(folderall)
              # lena = mpimg.imread(folderall)
              # lena.shape
              # plt.imshow(lena)  # 顯示圖片
              # plt.axis('off')  # 不顯示坐標軸
              # plt.show()
              # break
              output_8 = r'D:\test\out{}.tif'.format(i)
              compress(folderall, output_8)
              i=i+1

       

      posted on 2022-11-21 19:22  行走的蓑衣客  閱讀(354)  評論(0)    收藏  舉報
       
      主站蜘蛛池模板: 亚洲 成人 无码 在线观看| 午夜福利日本一区二区无码| av无码一区二区大桥久未| 国产高清精品在线91| 综合亚洲网| 义马市| 成人乱人伦精品小说| 亚洲午夜性猛春交xxxx| 色综合一本到久久亚洲91| 成人无码潮喷在线观看| 四房播色综合久久婷婷 | 亚洲午夜香蕉久久精品| 毛片无遮挡高清免费| 邵武市| 国产 麻豆 日韩 欧美 久久| 国产精品自在线拍国产手机版| 久久久久国色av免费看| 免费超爽大片黄| 国产熟女老阿姨毛片看爽爽| 亚洲欧洲自拍拍偷午夜色| 亚洲国产成人无码电影| 亚洲国产免费图区在线视频 | av中文字幕一区人妻| 欧美亚洲另类自拍偷在线拍| 国产精品日本一区二区不卡视频| 嘉义市| 精品国产迷系列在线观看| 国产精品免费AⅤ片在线观看| 国产宅男宅女精品A片在线观看| 久久人妻精品大屁股一区| 亚洲 卡通 欧美 制服 中文| 麻豆麻豆麻豆麻豆麻豆麻豆| 亚洲AV午夜电影在线观看| 男女爽爽无遮挡午夜视频| 国产极品粉嫩学生一线天| 人妻无码| 国产亚洲精品黑人粗大精选| 日韩中文字幕人妻精品| 美女自卫慰黄网站| 国产精品午夜福利91| 成人av天堂男人资源站|