Class: DicomS::Transfer
- Inherits:
-
Object
- Object
- DicomS::Transfer
- Extended by:
- Support
- Includes:
- Support
- Defined in:
- lib/dicoms/transfer.rb
Overview
Base class for Transfer strategy classes that define how the values of DICOM pixels are scales to be used as image pixels or to be processed as data (generic presentation values).
Different strategies determine how much of the original data dynamic range is preserved.
All the Transfer-derived classes can pass an :output option to the base which changes output range limits from what is stored in the DICOM. Two values are supported:
-
:byte Output consist of single byte values (0-255)
-
:unsigned Output is always unsigned
The method min_max(sequence) of each class returns the minimum and maximum values which are mapped to the output limits. These values may be raw or rescaled depending on the min_max_rescaled? method
Direct Known Subclasses
Constant Summary collapse
- USE_DATA =
false- FLOAT_MAPPING =
true
Class Method Summary collapse
Instance Method Summary collapse
-
#image(dicom, min, max) ⇒ Object
Remapped DICOM pixel values as an Image.
-
#initialize(options = {}) ⇒ Transfer
constructor
A new instance of Transfer.
-
#min_max_limits(dicom) ⇒ Object
absolute output limits of the range (raw, not rescaled).
-
#pixels(dicom, min, max) ⇒ Object
Remapped DICOM pixel values as an NArray.
Methods included from Support
assign_dicom_pixels, cast_metadata, decode_vector, define_transfer, dicom?, dicom_bit_depth, dicom_compression, dicom_element_value, dicom_name_pattern, dicom_narray, dicom_rescale_intercept, dicom_rescale_slope, dicom_signed?, dicom_stored_bits, dicom_window_center, dicom_window_width, encode_vector, find_dicom_files, keeping_path, normalized_path, output_file_name, pixel_value_range, single_dicom_metadata
Constructor Details
#initialize(options = {}) ⇒ Transfer
Returns a new instance of Transfer.
26 27 28 |
# File 'lib/dicoms/transfer.rb', line 26 def initialize( = {}) @output = [:output] end |
Class Method Details
.min_max_limits(dicom) ⇒ Object
82 83 84 85 86 |
# File 'lib/dicoms/transfer.rb', line 82 def self.min_max_limits(dicom) num_bits = dicom_bit_depth(dicom) signed = dicom_signed?(dicom) pixel_value_range(num_bits, signed) end |
.strategy(strategy, options = {}) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/dicoms/transfer.rb', line 41 def self.strategy(strategy, = {}) if strategy.is_a?(Array) && .empty? strategy, = strategy end return nil if strategy.nil? case strategy.to_sym when :fixed strategy_class = FixedTransfer when :window strategy_class = WindowTransfer when :first strategy_class = FirstTransfer when :global strategy_class = GlobalTransfer when :sample strategy_class = SampleTransfer when :identity strategy_class = IdentityTransfer else raise "INVALID: #{strategy.inspect}" end strategy_class.new end |
Instance Method Details
#image(dicom, min, max) ⇒ Object
Remapped DICOM pixel values as an Image
31 32 33 34 |
# File 'lib/dicoms/transfer.rb', line 31 def image(dicom, min, max) assign_dicom_pixels dicom, pixels(dicom, min, max) dicom.image end |
#min_max_limits(dicom) ⇒ Object
absolute output limits of the range (raw, not rescaled)
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/dicoms/transfer.rb', line 66 def min_max_limits(dicom) case @output when :byte [0, 255] when :unsigned min, max = Transfer.min_max_limits(dicom) if min < 0 min = 0 max -= min end [min, max] else Transfer.min_max_limits(dicom) end end |
#pixels(dicom, min, max) ⇒ Object
Remapped DICOM pixel values as an NArray
37 38 39 |
# File 'lib/dicoms/transfer.rb', line 37 def pixels(dicom, min, max) processed_data(dicom, min, max) end |