2011-07-28 16 views
1

我需要使用RMagick(用於ImageMagick的Ruby綁定)來比較兩個圖像的部分/部分。有沒有人與它有任何關係。使用RMagick進行局部圖像比較!

我使用compare_channel方法來生成圖像!我已經閱讀了文檔中的RMagick文檔和RMagick示例,並且我覺得我可以以某種方式使用 mask,但不知道如何?

任何想法?

回答

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