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

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

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12
      from PIL import Image
      from collections import Counter
      import numpy as np
      
      def save_colors_to_file(image_path, output_file):
          # 打開圖片文件
          image = Image.open(image_path)
          image = image.convert('RGB')
      
          # 將圖片轉換為numpy數組
          pixels = np.array(image)
      
          # 獲取所有顏色的RGB值,并轉換為元組形式,以便可以作為字典的鍵
          colors = [tuple(pixel) for pixel in pixels.reshape(-1, 3)]
      
          # 使用Counter統計每種顏色的出現次數
          color_counts = Counter(colors)
      
          # 按照出現次數從大到小排序顏色
          sorted_colors = sorted(color_counts.items(), key=lambda x: x[1], reverse=True)
      
          # 將RGB顏色轉換為HEX顏色
          hex_colors = [(f'#{int(r):02x}{int(g):02x}{int(b):02x}', count) for (r, g, b), count in sorted_colors]
      
          # 打開文件并寫入顏色信息
          with open(output_file, 'w') as file:
              for hex_color, count in hex_colors:
                  file.write(f'HEX: {hex_color}, Count: {count}\n')
      
      # 使用示例
      image_path = r'C:\壁紙\1.jpg'  # 替換為你的圖片路徑
      output_file = 'colors_output.txt'  # 輸出文件的路徑
      save_colors_to_file(image_path, output_file)

       2.占整體的百分比:

      from PIL import Image
      from collections import Counter
      import numpy as np
      
      def save_colors_to_file(image_path, output_file):
          # 打開圖片文件
          image = Image.open(image_path)
          image = image.convert('RGB')
      
          # 將圖片轉換為numpy數組
          pixels = np.array(image)
      
          # 獲取所有顏色的RGB值,并轉換為元組形式,以便可以作為字典的鍵
          colors = [tuple(pixel) for pixel in pixels.reshape(-1, 3)]
      
          # 使用Counter統計每種顏色的出現次數
          color_counts = Counter(colors)
      
          # 按照出現次數從大到小排序顏色
          sorted_colors = sorted(color_counts.items(), key=lambda x: x[1], reverse=True)
      
          # 計算總像素數
          total_pixels = len(pixels)
      
          # 將RGB顏色轉換為HEX顏色,并計算占比
          hex_colors_with_info = []
          for (r, g, b), count in sorted_colors:
              hex_color = f'#{int(r):02x}{int(g):02x}{int(b):02x}'
              percentage = (count / total_pixels) * 100
              hex_colors_with_info.append((hex_color, percentage))
      
          # 打開文件并寫入顏色信息
          with open(output_file, 'w', encoding='utf-8') as file:
              for hex_color, percentage in hex_colors_with_info:
                  file.write(f'HEX: {hex_color}, 占比: {percentage:.2f}%\n')
      
      # 使用示例
      image_path = r'C:\壁紙\1.jpg'   # 替換為你的圖片路徑
      output_file = 'colors_output_with_percentages.txt'  # 輸出文件的路徑
      save_colors_to_file(image_path, output_file)

       

      posted on 2024-09-16 19:45  大話人生  閱讀(229)  評論(0)    收藏  舉報
      主站蜘蛛池模板: 九九在线精品国产| 少妇人妻偷人精品系列| 日产精品久久久久久久| 乱码精品一区二区亚洲区| 亚洲精品中文字幕一二三| 色偷偷亚洲女人天堂观看| 亚洲熟妇自偷自拍另欧美| 一区二区三区精品偷拍| 亚洲夂夂婷婷色拍ww47| 国产精品v片在线观看不卡| 精品亚洲一区二区三区在线观看| 夜夜添无码一区二区三区| 永久免费的av在线电影网| 久久亚洲精品成人av秋霞| 中文字幕在线永久免费视频| 少妇xxxxx性开放| 夜夜夜高潮夜夜爽夜夜爰爰 | 日韩欧美亚洲综合久久| 精品国产乱弄九九99久久| 日本欧美一区二区免费视频| 中文人妻av高清一区二区| 国产人妻大战黑人20p| 又黄又硬又湿又刺激视频免费| 遂昌县| 久久久久蜜桃精品成人片公司 | 亚洲av永久无码精品水牛影视| 午夜免费福利小电影| 国产99青青成人A在线| 日本内射精品一区二区视频| 性姿势真人免费视频放| 亚洲综合91社区精品福利| 易门县| 中文字幕国产精品自拍| 人人妻人人做人人爽夜欢视频 | 男女性杂交内射女bbwxz| 人妻中文字幕亚洲一区| 国产成人av一区二区三| 亚洲av日韩av中文高清性色| 2019国产精品青青草原| 东莞市| 国产成人人综合亚洲欧美丁香花 |