Horizontal Histogram in OpenCV

前端 未结 4 1252
太阳男子
太阳男子 2020-12-19 14:15

I am newbie to OpenCV,now I am making a senior project related Image processing. I have a question: Can I make a horizontal or vertical histogram with some functions of Open

4条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-19 14:48

    Updating carnieri answer (some cv functions are not working today)

    import numpy as np
    import cv2
    
    def verticalProjection(img):
        "Return a list containing the sum of the pixels in each column"
        (h, w) = img.shape[:2]
        sumCols = []
        for j in range(w):
            col = img[0:h, j:j+1] # y1:y2, x1:x2
            sumCols.append(np.sum(col))
        return sumCols
    

    Regards.

提交回复
热议问题