使用RMagick进行部分图像比较!

时间:2011-07-28 05:10:09

标签: ruby imagemagick rmagick

我需要使用RMagick(用于ImageMagick的Ruby绑定)比较两个图像的部分/部分。有没有人跟它有任何关系。

我使用compare_channel方法生成图片!我已经阅读了文档中的RMagick文档和RMagick示例,我感觉我可以使用 mask以某种方式,但不确定如何?

有什么想法吗?

1 个答案:

答案 0 :(得分:2)

比较Image#export_pixels_to_string的结果应该可以解决问题:

area1_str = image1.export_pixels_to_string(xpos, ypos, width, height)
area2_str = image2.export_pixels_to_string(xpos, ypos, width, height)
if area1_str == area2_str
  puts "Equal"
else
  puts "Different"
end
相关问题