Module: DICOM::ImageProcessor

Included in:
ImageItem
Defined in:
lib/dicom/image_processor.rb,
lib/dicom/image_processor_r_magick.rb,
lib/dicom/image_processor_mini_magick.rb

Overview

This module is the general interface between the ImageItem class and the image methods found in the specific image processor modules.

Defined Under Namespace

Modules: DcmMiniMagick, DcmRMagick

Instance Method Summary collapse

Instance Method Details

#decompress(blobs) ⇒ Array<MagickImage>, FalseClass

Creates image objects from one or more compressed, binary string blobs.

Raises:

  • (ArgumentError)


13
14
15
16
17
18
19
20
21
# File 'lib/dicom/image_processor.rb', line 13

def decompress(blobs)
  raise ArgumentError, "Expected Array or String, got #{blobs.class}." unless [String, Array].include?(blobs.class)
  blobs = [blobs] unless blobs.is_a?(Array)
  begin
    return image_module.decompress(blobs)
  rescue
    return false
  end
end

#export_pixels(image, photometry) ⇒ Array<Integer>

Extracts an array of pixels (integers) from an image object.

Raises:

  • (ArgumentError)


29
30
31
32
# File 'lib/dicom/image_processor.rb', line 29

def export_pixels(image, photometry)
  raise ArgumentError, "Expected String, got #{photometry.class}." unless photometry.is_a?(String)
  image_module.export_pixels(image, photometry)
end

#import_pixels(blob, columns, rows, depth, photometry) ⇒ MagickImage

Creates an image object from a binary string blob.

Raises:

  • (ArgumentError)


43
44
45
46
# File 'lib/dicom/image_processor.rb', line 43

def import_pixels(blob, columns, rows, depth, photometry)
  raise ArgumentError, "Expected String, got #{blob.class}." unless blob.is_a?(String)
  image_module.import_pixels(blob, columns, rows, depth, photometry)
end

#valid_image_objectsArray<String>

Gives an array containing the image objects that are supported by the image processor.



52
53
54
# File 'lib/dicom/image_processor.rb', line 52

def valid_image_objects
  return ['Magick::Image', 'MiniMagick::Image']
end