Created
May 18, 2015 10:06
-
-
Save ejangi/2d7d2485794f83cdc1a6 to your computer and use it in GitHub Desktop.
Convert DICOM images to JPG
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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