Skip to content

Instantly share code, notes, and snippets.

@ejangi
Created May 18, 2015 10:06
Show Gist options
  • Save ejangi/2d7d2485794f83cdc1a6 to your computer and use it in GitHub Desktop.
Save ejangi/2d7d2485794f83cdc1a6 to your computer and use it in GitHub Desktop.
Convert DICOM images to JPG
# CONVERT DICOM IMAGES TO JPG
# Needs Imagemagick, plus the Rmagic and Dicom gems:
#$ gem install rmagic
#$ gem install dicom
require 'dicom'
include DICOM
files = Dir.glob("/path/to/dicom/image/files/*")
puts files.length
files.each do |f|
if !File.directory? f then
dcm = DObject.read(f)
dcm_image = dcm.image
dcm_image.normalize.write(f + ".jpg")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment