相关疑难解决方法(0)

使用Ruby和imagemagick获取或计算图像的熵

如何在Ruby中找到带有imagemagick的"entropy",最好是mini_magic?我需要这个作为一个更大的项目的一部分,在图像中找到"有趣",以便裁剪它.

在Python/Django中找到了一个很好的例子,它提供了以下伪代码:

image = Image.open('example.png')
histogram = image.histogram() # Fetch a list of pixel counts, one for each pixel value in the source image

#Normalize, or average the result.
for each histogram as pixel
  histogram_recalc << pixel / histogram.size
endfor

#Place the pixels on a logarithmic scale, to enhance the result.
for each histogram_recalc as pixel
  if pixel != 0
    entropy_list << log2(pixel)
  endif
endfor

#Calculate the total of the enhanced pixel-values and invert(?) …
Run Code Online (Sandbox Code Playgroud)

ruby image-manipulation imagemagick entropy

5
推荐指数
1
解决办法
2573
查看次数

标签 统计

entropy ×1

image-manipulation ×1

imagemagick ×1

ruby ×1