module DICOM::ImageProcessor
This module is the general interface between the ImageItem
class and the image methods found in the specific image processor modules.
Public Instance Methods
Creates image objects from one or more compressed, binary string blobs.
@param [Array<String>, String] blobs binary string blob(s) containing compressed pixel data @return [Array<MagickImage>, FalseClass] - an array of images, or false (if decompression failed)
# 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
Extracts an array of pixels (integers) from an image object.
@param [MagickImage] image a Magick image object @param [String] photometry a code describing the photometry of the pixel data (e.g. 'MONOCHROME1' or 'COLOR') @return [Array<Integer>] an array of pixel values
# 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
Creates an image object from a binary string blob.
@param [String] blob binary string blob containing pixel data @param [Integer] columns the number of columns @param [Integer] rows the number of rows @param [Integer] depth the bit depth of the encoded pixel data @param [String] photometry a code describing the photometry of the pixel data (e.g. 'MONOCHROME1' or 'COLOR') @return [MagickImage] a Magick image object
# 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
Gives an array containing the image objects that are supported by the image processor.
@return [Array<String>] the valid image classes
# File lib/dicom/image_processor.rb, line 52 def valid_image_objects return ['Magick::Image', 'MiniMagick::Image'] end
Private Instance Methods
Gives the specific image processor module corresponding to the specified image_processor module option.
@raise [RuntimeError] if an unknown image processor is specified @return [DcmMiniMagick, DcmRMagick] the image processor module to be used
# File lib/dicom/image_processor.rb, line 66 def image_module case DICOM.image_processor when :mini_magick require 'mini_magick' DcmMiniMagick when :rmagick require 'rmagick' DcmRMagick else raise "Uknown image processor #{DICOM.image_processor}" end end