Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

统计图像里面的值 #204

Open
junxnone opened this issue May 11, 2020 · 0 comments
Open

统计图像里面的值 #204

junxnone opened this issue May 11, 2020 · 0 comments

Comments

@junxnone
Copy link
Owner

junxnone commented May 11, 2020

统计图像里面的值

  • 验证 segmentation mask 的值
  • 统计 pixel max/min/mean, 设置阈值

cv2.calcHist()

img_hist = cv2.calcHist([gray_img],[0], None,[256],[0,255])
pixel_list = np.nonzero(img_hist)[0].tolist()
  • img_hist.shape - (256, 1)
  • img_hist[N] 对应 pixel N 统计数
  • 速度比 Counter 快很多

collections.Counter

import cv2
import numpy as np
from collections import  Counter

def summary_image_mask(mask_img_path):
    mask_img = cv2.imread(mask_img_path)
    print(f'{mask_img_path}:\n{Counter(mask_img.flatten())}')

img_mask_path = 'xxx'
summary_image_mask(img_mask_path )

Reference

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant