I was presented with a problem by another user which is quite similar to the one given above, so I thought I'd post the solution here as well, to the benefit of everyone. The problem is this: How to create a single frame dicom file from a color jpg image? A working script is given below (this was tested with ruby-dicom 0.9.5 and RMagick 2.13.2).
Regards,
Chris
require 'dicom'
require 'RMagick'
include DICOM
include Magick
image = Image.read('color.jpg').first
# Create DICOM object and tags:
dcm = DObject.new
dcm.transfer_syntax = '1.2.840.10008.1.2.4.50'
dcm.sop_class_uid = '1.2.840.10008.5.1.4.1.1.3.1'
dcm.sop_instance_uid = DICOM.generate_uid
dcm.study_date = Time.now.strftime('%Y.%m.%d')
dcm.study_time = Time.now.strftime('%H:%M:%S')
dcm.modality = 'US'
dcm.manufacturer = 'ruby-dicom'
dcm.patients_name = 'Test'
dcm.patient_id = '12345'
dcm.study_instance_uid = DICOM.generate_uid
dcm.series_instance_uid = DICOM.generate_uid
dcm.study_id = '1'
dcm.series_number = '32'
dcm.instance_number = '142'
dcm.image_position_patient = "0.0\\0.0\\0.0"
dcm.image_orientation_patient = "1\\0\\0\\0\\1\\0"
dcm.frame_of_reference_uid = DICOM.generate_uid
dcm.samples_per_pixel = 3
dcm.photometric_interpretation = 'YBR_FULL_422'
dcm.number_of_frames = 1
dcm.rows = image.rows
dcm.columns = image.columns
dcm.pixel_spacing = "1.0\\1.0"
dcm.bits_allocated = 8
dcm.bits_stored = 8
dcm.high_bit = 7
dcm.pixel_representation = 0
# Create pixel tags/items:
pixel_data_seq = Sequence.new('7FE0,0010', :parent => dcm, :vr => 'OB')
basic_offset_table_item = Item.new(:length => 0, :parent => pixel_data_seq)
frame_item = Item.new(:bin => image.to_blob, :parent => basic_offset_table_item)
dcm.write('color.dcm')