Class: Sqed::BoundaryFinder::StageFinder
- Inherits:
-
Sqed::BoundaryFinder
- Object
- Sqed::BoundaryFinder
- Sqed::BoundaryFinder::StageFinder
- Defined in:
- lib/sqed/boundary_finder/stage_finder.rb
Overview
Some of this code was originally inspired by Emmanuel Oga’s gist gist.github.com/EmmanuelOga/2476153.
Constant Summary collapse
- MIN_CROP_RATIO =
How small we accept a cropped picture to be. E.G. if it was 100x100 and ratio 0.1, min output should be 10x10
0.1
Constants inherited from Sqed::BoundaryFinder
Instance Attribute Summary collapse
-
#columns ⇒ Object
readonly
Returns the value of attribute columns.
-
#is_border ⇒ Object
readonly
The proc containing the border finding algorithim.
-
#min_height ⇒ Object
readonly
Returns the value of attribute min_height.
-
#min_width ⇒ Object
readonly
Returns the value of attribute min_width.
-
#rows ⇒ Object
readonly
Returns the value of attribute rows.
-
#x0 ⇒ Object
readonly
Returns the value of attribute x0.
-
#x1 ⇒ Object
readonly
Returns the value of attribute x1.
-
#y0 ⇒ Object
readonly
Returns the value of attribute y0.
-
#y1 ⇒ Object
readonly
Returns the value of attribute y1.
Attributes inherited from Sqed::BoundaryFinder
#boundaries, #image, #layout, #original_image, #use_thumbnail
Instance Method Summary collapse
-
#initialize(**opts) ⇒ StageFinder
constructor
A new instance of StageFinder.
Methods inherited from Sqed::BoundaryFinder
color_boundary_finder, derivative, derivative_signs, frequency_stats, get_subdivision_size, #height_factor, is_black?, is_blue?, is_green?, is_red?, #longest_thumbnail_axis, max_difference, max_pairwise_difference, sample_border, #thumbnail, #thumbnail_height, #thumbnail_width, #width_factor, #zoom_boundaries
Constructor Details
#initialize(**opts) ⇒ StageFinder
Returns a new instance of StageFinder.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/sqed/boundary_finder/stage_finder.rb', line 18 def initialize(**opts) image = opts[:image] is_border_proc = opts[:is_border_proc] min_ratio = opts[:min_ratio] min_ratio ||= MIN_CROP_RATIO super(image: image, layout: :internal_box) @min_ratio = min_ratio # Initial co-ordinates @x0, @y0 = 0, 0 @x1, @y1 = image.columns, image.rows @min_width, @min_height = image.columns * @min_ratio, image.rows * @min_ratio # minimum resultant area @columns, @rows = image.columns, image.rows # We need a border finder proc. Provide one if none was given. @is_border = is_border_proc || self.class.default_border_finder(image) # if no proc specified, use default below @x00 = @x0 @y00 = @y0 @height0 = height @width0 = width find_edges end |
Instance Attribute Details
#columns ⇒ Object (readonly)
Returns the value of attribute columns.
16 17 18 |
# File 'lib/sqed/boundary_finder/stage_finder.rb', line 16 def columns @columns end |
#is_border ⇒ Object (readonly)
The proc containing the border finding algorithim
8 9 10 |
# File 'lib/sqed/boundary_finder/stage_finder.rb', line 8 def is_border @is_border end |
#min_height ⇒ Object (readonly)
Returns the value of attribute min_height.
16 17 18 |
# File 'lib/sqed/boundary_finder/stage_finder.rb', line 16 def min_height @min_height end |
#min_width ⇒ Object (readonly)
Returns the value of attribute min_width.
16 17 18 |
# File 'lib/sqed/boundary_finder/stage_finder.rb', line 16 def min_width @min_width end |
#rows ⇒ Object (readonly)
Returns the value of attribute rows.
16 17 18 |
# File 'lib/sqed/boundary_finder/stage_finder.rb', line 16 def rows @rows end |
#x0 ⇒ Object (readonly)
Returns the value of attribute x0.
16 17 18 |
# File 'lib/sqed/boundary_finder/stage_finder.rb', line 16 def x0 @x0 end |
#x1 ⇒ Object (readonly)
Returns the value of attribute x1.
16 17 18 |
# File 'lib/sqed/boundary_finder/stage_finder.rb', line 16 def x1 @x1 end |
#y0 ⇒ Object (readonly)
Returns the value of attribute y0.
16 17 18 |
# File 'lib/sqed/boundary_finder/stage_finder.rb', line 16 def y0 @y0 end |
#y1 ⇒ Object (readonly)
Returns the value of attribute y1.
16 17 18 |
# File 'lib/sqed/boundary_finder/stage_finder.rb', line 16 def y1 @y1 end |