我们如何获得图像的强度直方图,哪种工具正在使用?

时间:2017-08-04 03:35:21

标签: image-processing computer-vision image-segmentation

enter image description here

朋友你好, 希望你们都很好。实际上我正在进行图像处理,我希望得到图像的强度,如附图所示。图像使用元素(像素)的强度构建。我想获得图像的强度(像素范围0-255)直方图。我不知道怎么做以及将使用哪种工具来获取它?请帮忙....谢谢

1 个答案:

答案 0 :(得分:1)

您显示的直方图与您的扫描不匹配 - 扫描的直方图中没有大量暗像素。

无论如何,您可以使用 ImageMagick 在命令行中非常简单地生成直方图,该驱动程序安装在大多数Linux发行版上,可用于macOS和Windows。

所以,从这开始:

enter image description here

命令是这样的:

convert image.jpg histogram:result.png

enter image description here

如果您不希望按颜色细分,可以像这样转换为灰度:

convert image.jpg -colorspace gray histogram:intensity.png

enter image description here

所以,对于你的形象:

convert scan.jpg histogram:scanI.png

enter image description here

如果您想要黑色的白色,可以将其反转并在其周围放置边框:

convert scanI.png -negate -bordercolor black -border 1 scanI.png

enter image description here

如果您想要文本格式的值,可以使用:

convert scan.jpg -colorspace gray -format %c histogram:info:-

     4: (  0,  0,  0) #000000 gray(0)
    10: (  1,  1,  1) #010101 gray(1)
     8: (  1,  1,  1) #010101 gray(1)
    19: (  2,  2,  2) #020202 gray(2)
     9: (  2,  2,  2) #020202 gray(2)
    52: (  3,  3,  3) #030303 gray(3)
    20: (  3,  3,  3) #030303 gray(3)
   116: (  4,  4,  4) #040404 gray(4)
    42: (  4,  4,  4) #040404 gray(4)
   321: (  5,  5,  5) #050505 gray(5)
   266: (  5,  5,  5) #050505 gray(5)
     5: (  5,  5,  5) #050505 gray(5)
 12058: (  6,  6,  6) #060606 gray(6)
    79: (  6,  6,  6) #060606 gray(6)
     1: (  6,  6,  6) #060606 gray(6)
   778: (  7,  7,  7) #070707 gray(7)
    66: (  7,  7,  7) #070707 gray(7)
     1: (  7,  7,  7) #070707 gray(7)
   269: (  8,  8,  8) #080808 gray(8)
    45: (  8,  8,  8) #080808 gray(8)
   127: (  9,  9,  9) #090909 gray(9)
    34: (  9,  9,  9) #090909 gray(9)
     1: (  9,  9,  9) #090909 gray(9)
    53: ( 10, 10, 10) #0A0A0A gray(10)
    27: ( 10, 10, 10) #0A0A0A gray(10)
    28: ( 11, 11, 11) #0B0B0B gray(11)
    23: ( 11, 11, 11) #0B0B0B gray(11)
    21: ( 12, 12, 12) #0C0C0C gray(12)
    28: ( 12, 12, 12) #0C0C0C gray(12)
    ...
    ...