lib/sqed/boundary_finder.rb in sqed-0.1.0 vs lib/sqed/boundary_finder.rb in sqed-0.1.1
- old
+ new
@@ -1,7 +1,5 @@
-require 'RMagick'
-
# Sqed Boundary Finders find boundaries on images and return co-ordinates of those boundaries. They do not
# return derivative images. Finders operate on cropped images, i.e. only the "stage".
#
class Sqed::BoundaryFinder
# the passed image
@@ -13,11 +11,11 @@
# A Sqed::Boundaries instance, stores the coordinates of all of the layout sections
attr_reader :boundaries
def initialize(image: image, layout: layout)
raise 'No layout provided.' if layout.nil?
- raise 'No image provided.' if image.nil? || image.class != Magick::Image
+ raise 'No image provided.' if image.nil? || image.class.name != 'Magick::Image'
@layout = layout
@img = image
true
end
@@ -50,12 +48,12 @@
samples_to_take = (image.send(scan) / sample_subdivision_size).to_i - 1
(0..samples_to_take).each do |s|
# Create a sample image a single pixel tall
if scan == :rows
- j = image.crop(0, s * sample_subdivision_size, image.columns, 1, true)
+ j = image.crop(0, s * sample_subdivision_size, image.columns, 1)
elsif scan == :columns
- j = image.crop(s * sample_subdivision_size, 0, 1, image.rows, true)
+ j = image.crop(s * sample_subdivision_size, 0, 1, image.rows)
else
raise
end
j.each_pixel do |pixel, c, r|