spec/spec_helper.rb
# Computes the RMS value between two images
Computes the RMS value between two images
Computes the RMS value between two images
def compute_rms(test_image, reference_image)
  image1 = Magick::Image.read(('spec/reference_images/' + test_image)).first
  image2 = Magick::Image.read(('spec/reference_images/' + reference_image)).first
  diff = 0
  pixel_array_1 = image1.export_pixels
  pixel_array_2 = image2.export_pixels
  for i in 0..(pixel_array_1.size - 1)
    diff += ((pixel_array_1[i] - pixel_array_2[i]).abs / 3)**2
  end
  Math.sqrt(diff / (512 * 512))
end
def compute_rms ( test_image , reference_image ) image1 = Magick :: Image . read ( ( 'spec/reference_images/' + test_image ) ) . first image2 = Magick :: Image . read ( ( 'spec/reference_images/' + reference_image ) ) . first diff = 0 pixel_array_1 = image1 . export_pixels pixel_array_2 = image2 . export_pixels for i in 0 .. ( pixel_array_1 . size - 1 ) diff += ( ( pixel_array_1 [ i ] - pixel_array_2 [ i ] ) . abs / 3 ) ** 2 end Math . sqrt ( diff / ( 512 * 512 ) ) end
Computes the RMS value between two images
Computes the RMS value between two images
test_image
<not_specific>
reference_image
<not_specific>