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.

Parameters:

  • blobs (Array<String>, String)

    binary string blob(s) containing compressed pixel data

Returns:

  • (Array<MagickImage>, FalseClass)
    • an array of images, or false (if decompression failed)

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.

Parameters:

  • image (MagickImage)

    a Magick image object

  • photometry (String)

    a code describing the photometry of the pixel data (e.g. ‘MONOCHROME1’ or ‘COLOR’)

Returns:

  • (Array<Integer>)

    an array of pixel values

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.

Parameters:

  • blob (String)

    binary string blob containing pixel data

  • columns (Integer)

    the number of columns

  • rows (Integer)

    the number of rows

  • depth (Integer)

    the bit depth of the encoded pixel data

  • photometry (String)

    a code describing the photometry of the pixel data (e.g. ‘MONOCHROME1’ or ‘COLOR’)

Returns:

  • (MagickImage)

    a Magick image object

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.

Returns:



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

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