DDSM数据库转换图像格式——LJPEG转为PNG格式

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
  • 4
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 51
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 51
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值