Class: SnapDiff::ImagePreprocessor

Inherits:
Object
  • Object
show all
Defined in:
lib/snap_diff/image_preprocessor.rb

Overview

Handles image preprocessing operations (skip_area and median filtering)

This class applies preprocessing filters to images before comparison, such as masking specific regions (skip_area) or applying noise reduction. It's designed to work with either direct image objects or with options.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(driver, options = {}) ⇒ ImagePreprocessor

Returns a new instance of ImagePreprocessor.



12
13
14
15
# File 'lib/snap_diff/image_preprocessor.rb', line 12

def initialize(driver, options = {})
  @driver = driver
  @options = options
end

Instance Attribute Details

#driverObject (readonly)

Returns the value of attribute driver.



10
11
12
# File 'lib/snap_diff/image_preprocessor.rb', line 10

def driver
  @driver
end

#optionsObject (readonly)

Returns the value of attribute options.



10
11
12
# File 'lib/snap_diff/image_preprocessor.rb', line 10

def options
  @options
end

Instance Method Details

#process_comparison(comparison) ⇒ Comparison

Process a comparison object directly This allows reusing the comparison's existing options

Parameters:

  • comparison (Comparison)

    the comparison object

Returns:



21
22
23
24
25
26
27
# File 'lib/snap_diff/image_preprocessor.rb', line 21

def process_comparison(comparison)
  # Process both images
  comparison.base_image = process_image(comparison.base_image, comparison.base_image_path)
  comparison.new_image = process_image(comparison.new_image, comparison.new_image_path)

  comparison
end