Digital Database for Screening Mammography (DDSM)数据库是一个非常大的乳腺图像数据库,有一万多张图像,但是图像格式是LJPEG,现有的图像软件(如photoshop、ACCDsee、windows自带的图像查看软件)以及编程软件(如matlab)都无法读取,需要将其转换成其他常见的格式才能使用。我从网上搜到了很多方法,试过之后都不成功,其中包括该数据库的创建者——南佛罗里达大学自己写的一个程序[1],一个医学图像格式转换软件XMedCon[2]。最后成功的方法是使用曼彻斯特大学的Dr. Chris Rose写的一个完整的程序,在他的程序基础上做了些修改,成功的将图像格式转换成了PNG格式。他的程序链接见http://microserf.org.uk/academic/Software.html (PS. 最近发现此链接地址已失效,所以我把源程序放在了我的github上,地址:https://github.com/hd11224/DDSM,包括了所有需要的工具和软件)
从上面给出的链接下载到的程序中,有用户手册告诉你怎么使用这个程序。这个程序是用Ruby语言写的,需要在Cygwin下运行,用户手册中有介绍如何安装Cygwin及其他需要的工具。程序工作流程是使用者手动输入图像名称,程序先从FTP上下载该图像,然后经过几步转换,最终转换为PNG格式。我在按照用户手册运行这个程序时没有成功,用VS2013打开get-ddsm-mammo文件查看源码,发现是从FTP上下载图像环节出了问题,做了修改后,最终运行成功。我修改后的程序如下:
#!/usr/bin/ruby
# This program gets a specified mammogram from the DDSM website and
# converts it to a PNG image. See the help message for full details.
require 'net/ftp'
# Specify the name of the info-file.
def info_file_name
'info-file.txt'
end
def image_names
'image_name.txt'
end
# Get an FTP file as specified by a DDSM path (e.g.,
# /pub/DDSM/cases/cancers/cancer_06/case1141/A-1141-1.ics) and return the
# local path to the file, or return nil if the file could not be dowloaded.
def get_file_via_ftp(ddsm_path)
ftp = Net::FTP.new('figment.csee.usf.edu')
ftp.passive = true
ftp.login
ftp.chdir(File.dirname(ddsm_path))
puts File.basename(ddsm_path)
ftp.getbinaryfile(File.basename(ddsm_path))
#ftp.getbinaryfile(ddsm_path)
# Will be stored local to this program, under the same file name
# Check to make sure that we managed to get the file.
if !FileTest.exist?(File.basename(ddsm_path))
puts "Could not get the file #{File.basename(ddsm_path)} from the DDSM FTP server; perhaps the server is busy."
exit(-1)
end
return File.basename(ddsm_path)
end
# Return the string input with the system's filesep at the end; if there
# is one there already then return input.
def ensure_filesep_terminated(input)
if input[input.length-1].chr != File::SEPARATOR
input += File::SEPARATOR
end
return input
end
# Check program input; input is the program input (i.e ARGV).
def check_inputs(input)
if input.length != 1
puts get_help
exit(-1)
end
# See if the user wanted the help docs.
if input[0] == '--help'
puts get_help
exit(-1)
end
# Chec