//======================================================================================
// NanJing ChunRen L.T.D
// Created by HGB
//======================================================================================
/*convert.h*/
#ifdef __cplusplus
extern "C" {
#endif
// 下列部分用于定义SCU/SCP回调函数
//typedef void (__stdcall * STORESCPCALLBACK)(T_StoreProgress* progress, LPCSTR filename);
// 下列函数用于处理SCU高级网络服务
/*BOOL __stdcall dicom_echoscu_execute(LPCSTR servername, int serverport,
LPCSTR servertitle, LPCSTR clienttitle);
BOOL __stdcall dicom_storescu_execute(LPCSTR servername, int serverport,
LPCSTR servertitle, LPCSTR clienttitle,
LPCSTR filelist, STORESCUCALLBACK callback);*/
// 下列函数用于处理SCP高级网络服务
//int __declspec(dllexport) IncInt(int params);
bool __stdcall jpg2dcm(LPSTR BmpSrc, LPSTR DcmDest, LPSTR PatientName, LPSTR PatientSex);
//int __stdcall(dllexport) IncInt(int params);
#ifdef __cplusplus
}
#endif
#ifdef __cplusplus
extern "C" {
#endif
// 下列部分用于定义SCU/SCP回调函数
//typedef void (__stdcall * STORESCPCALLBACK)(T_StoreProgress* progress, LPCSTR filename);
// 下列函数用于处理SCU高级网络服务
/*BOOL __stdcall dicom_echoscu_execute(LPCSTR servername, int serverport,
LPCSTR servertitle, LPCSTR clienttitle);
BOOL __stdcall dicom_storescu_execute(LPCSTR servername, int serverport,
LPCSTR servertitle, LPCSTR clienttitle,
LPCSTR filelist, STORESCUCALLBACK callback);*/
// 下列函数用于处理SCP高级网络服务
//int __declspec(dllexport) IncInt(int params);
bool __stdcall jpg2dcm(LPSTR BmpSrc, LPSTR DcmDest, LPSTR PatientName, LPSTR PatientSex);
//int __stdcall(dllexport) IncInt(int params);
#ifdef __cplusplus
}
#endif
//======================================================================================
// NanJing ChunRen L.T.D
// Created by HGB
//======================================================================================
/*convert.cpp*/
// convert.cpp : Defines the entry point for the DLL application.
//
#include "stdafx.h"
//#include <afx.h>
#include "convert.h"
#include "xImageDCM.h"
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
int IncInt(int params)
{
return params+1;
}
bool __stdcall jpg2dcm(LPSTR BmpSrc, LPSTR DcmDest, LPSTR PatientID, LPSTR PatientName,
LPSTR PatientSex, LPSTR StudyDate)
{
CxImageDCM dcm;
//CString m_sBmpSrcFile;
//CString m_sDcmDestFile;
//dcm.Load(BmpSrc,CXIMAGE_FORMAT_BMP);
dcm.Load(BmpSrc,CXIMAGE_FORMAT_JPG);
if(!dcm.IsValid()){
return false;
}else{
/*m_sBmpSrcFile=filename;
m_sDcmDestFile=m_sBmpSrcFile;
m_sDcmDestFile.TrimRight(filename);
m_sDcmDestFile+=_T("dcm");*/
//if(dcm.SaveAsDCM(m_sDcmDestFile))
if(dcm.SaveAsDCM(DcmDest, PatientID, PatientName, PatientSex, StudyDate))
{
return true;
}
else
{
return false;
}
}
}
//======================================================================================
// NanJing ChunRen L.T.D
// Created by HGB
//======================================================================================
// xImageDCM.cpp: implementation of the CxImageDCM class.
//
//////////////////////////////////////////////////////////////////////
#include "StdAfx.h"
//#include "DCMConverter.h"
#include "xImageDCM.h"
#include "osconfig.h" /* make sure OS specific configuration is included first */
#ifdef HAVE_GUSI_H
#include <GUSI.h>
#endif
#include "dctk.h" /* for various dcmdata headers */
#include "dcdebug.h" /* for SetDebugLevel */
#include "cmdlnarg.h" /* for prepareCmdLineArgs */
#include "dcuid.h" /* for dcmtk version name */
#include "dcrledrg.h" /* for DcmRLEDecoderRegistration */
#include "dcmimage.h" /* for DicomImage */
#include "digsdfn.h" /* for DiGSDFunction */
#include "diciefn.h" /* for DiCIELABFunction */
#include "ofconapp.h" /* for OFConsoleApplication */
#include "ofcmdln.h" /* for OFCommandLine */
#include "diregist.h" /* include to support color images */
#include "ofstd.h" /* for OFStandard */
#include "djdecode.h" /* for dcmjpeg decoders */
#include "dipijpeg.h" /* for dcmimage JPEG plugin */
#include "dipitiff.h" /* for dcmimage TIFF plugin */
#include "dipipng.h" /* for dcmimage PNG plugin */
#include "zlib.h" /* for zlibVersion() */
#include "ofstream.h"
/*#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif*/
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CxImageDCM::CxImageDCM()
{
//init pointers
pDib = pSelection = pAlpha = NULL;
pLayers = NULL;
//init structures
memset(&head,0,sizeof(BITMAPINFOHEADER));
memset(&info,0,sizeof(CXIMAGEINFO));
//init default attributes
info.dwType = 0;
info.nQuality = 90;
info.nAlphaMax = 255;
info.nBkgndIndex = -1;
info.bEnabled = true;
SetXDPI(96);
SetYDPI(96);
}
CxImageDCM::~CxImageDCM()
{
}
bool CxImageDCM::SaveAsBMP(const TCHAR *fileName)
{//please refer to the implementation of dcmj2pnm
return false;
}
bool CxImageDCM::SaveAsJPG(const TCHAR* fileName)
{//you may also use DCMTK's JPG encoding plug-in
return CxImage::Save(fileName,CXIMAGE_FORMAT_JPG);
}
bool CxImageDCM::LoadDCM(const TCHAR* filename)
{
DcmFileFormat *dfile = new DcmFileFormat();
OFCondition cond = dfile->loadFile(filename, EXS_Unknown,
EGL_withoutGL,DCM_MaxReadLength,ERM_autoDetect);
if (cond.bad()) {
return false;//AfxMessageBox(cond.text());
}
E_TransferSyntax xfer = dfile->getDataset()->getOriginalXfer();
DicomImage *di = new DicomImage(dfile, xfer,
CIF_AcrNemaCompatibility ,
0, 1);
if (di->getStatus() != EIS_Normal)
return false;//AfxMessageBox(DicomImage::getString(di->getStatus()));
//可改为MemoryStream操作,以替换不安全低效的临时文件
di->writeBMP("c:\\from_dicom.bmp",24);
return CxImage::Load("c:\\from_dicom.bmp",CXIMAGE_FORMAT_BMP);
}
bool CxImageDCM::SaveAsDCM(const TCHAR* filename, const TCHAR* PatientID,
const TCHAR* PatientName, const TCHAR* PatientSex,
const TCHAR* StudyDate)
{
CxImageDCM::IncreaseBpp(24);
char uid[100];
DcmFileFormat fileformat;
DcmDataset *dataset = fileformat.getDataset();
dataset->putAndInsertString(DCM_SOPClassUID,
UID_SecondaryCaptureImageStorage);
dataset->putAndInsertString(DCM_SOPInstanceUID,
dcmGenerateUniqueIdentifier(uid, SITE_INSTANCE_UID_ROOT));
dataset->putAndInsertString(DCM_StudyInstanceUID ,
dcmGenerateUniqueIdentifier(uid, SITE_INSTANCE_UID_ROOT));
dataset->putAndInsertString(DCM_SeriesInstanceUID ,
dcmGenerateUniqueIdentifier(uid, SITE_INSTANCE_UID_ROOT));
dataset->putAndInsertString(DCM_Modality,"OT");
dataset->putAndInsertString(DCM_PatientID, PatientID);
dataset->putAndInsertString(DCM_PatientsName, PatientName);
dataset->putAndInsertString(DCM_PatientsSex, PatientSex);
dataset->putAndInsertString(DCM_StudyDate, StudyDate);
dataset->putAndInsertString(DCM_WindowCenter, "256");
dataset->putAndInsertString(DCM_WindowWidth, "128");
// dataset->putAndInsertUint32(DCM_MetaElementGroupLength,128);
dataset->putAndInsertUint16(DCM_FileMetaInformationVersion,
0x0001);
dataset->putAndInsertString(DCM_MediaStorageSOPClassUID,
UID_MultiframeTrueColorSecondaryCaptureImageStorage);
dataset->putAndInsertString(DCM_MediaStorageSOPInstanceUID,
dcmGenerateUniqueIdentifier(uid,SITE_INSTANCE_UID_ROOT));
dataset->putAndInsertString(DCM_TransferSyntaxUID,
UID_LittleEndianExplicitTransferSyntax);
/*added by HGB*/
//dataset->findAndDeleteElement(DCM_ImplementationClassUID, OFTrue);
//dataset->findAndDeleteElement(DCM_ImplementationVersionName, OFTrue);
//end added
//dataset->putAndInsertString(DCM_ImplementationClassUID,
// dcmGenerateUniqueIdentifier(uid,SITE_INSTANCE_UID_ROOT));
//dataset->putAndInsertString(DCM_ImplementationVersionName,
// "SEEKERSOFT1.3.01", OFTrue);
dataset->putAndInsertString(DCM_UID,
UID_MultiframeTrueColorSecondaryCaptureImageStorage);
dataset->putAndInsertUint16(DCM_SamplesPerPixel,3);
dataset->putAndInsertString(DCM_PhotometricInterpretation,
"RGB");
dataset->putAndInsertUint16(DCM_SamplesPerPixel,3);
dataset->putAndInsertUint16(DCM_BitsAllocated,8);
dataset->putAndInsertUint16(DCM_BitsStored,8);
dataset->putAndInsertUint16(DCM_HighBit,7);
dataset->putAndInsertUint16(DCM_PixelRepresentation,0);
dataset->putAndInsertUint16(DCM_PlanarConfiguration,0);
dataset->putAndInsertUint16(DCM_Rows,GetHeight());
dataset->putAndInsertUint16(DCM_Columns,GetWidth());
//add more tags here
/* ... */
BYTE* pData=new BYTE[GetHeight()*info.dwEffWidth];
BYTE* pSrc=GetBits(head.biHeight-1);
BYTE* pDst=pData;
for(long y=0; y < head.biHeight; y++){
memcpy(pDst,pSrc,info.dwEffWidth);
pSrc-=info.dwEffWidth;
pDst+=info.dwEffWidth;
}
dataset->putAndInsertUint8Array(DCM_PixelData,
pData, GetHeight()*info.dwEffWidth);
delete[] pData;
OFCondition status = fileformat.saveFile(filename,
EXS_LittleEndianImplicit,EET_UndefinedLength,EGL_withoutGL);
if (status.bad())
return false;//AfxMessageBox("Error: cannot write DICOM file ");
return true;
}
分享到:
相关推荐
Dicom 转Jpeg 支持3种不同的方式转换将dicom转成jpeg Jpeg 转Dicom, 可以将jpeg png等主流图片格式转为dicom文件
可以利用该工具对JPEG2000压缩的DICOM文件进行解压缩,另外一个功能就是对一个文件夹内的不同序列DICOM文件按照序列进行分类,分类后文件目录结构为:病人--study-serial
读取DICOM图像文件,经实际运行可实现请放心下载
自己根据DICOM 协议写的dicom文件读取程序,程序包括DICOM文件读取,图像分割,三维重建,边缘检测的功能
在vs2015下测试正常,可将医疗图像以dcm为后缀的图像转换为jpg文件,可将医疗图像以dcm为后缀的图像转换为jpg文件,希望对大家有所帮助。
心电图DICOM文件
有志于研究医学图像的朋友可以下载这个资料,dicom文件格式是核磁共振图像的一种。
单个CT影像文件,用于软件开发同学测试使用,胸部CT dicom文件。
WPF开发DICOM文件读写小工具,基于fo-dicom,实现DICOM文件的读取、解析,根据XML文件批量生成并导出DICOM文件
dicom文件信息批量修改,添加dicom信息,如修改患者ID,或者添加缺失的dicom信息,非常好用,本工具非本人原创,转发其他大神的,本人测试在win10 64位下正常使用,
可以实现简单的dicom文件的打开,显示图像,以及可以读取dcm文件中的其他一些信息。
dicom文件包,提供下载方便大家测试。
主要介绍了vue展示dicom文件医疗系统的实现代码,非常不错,具有一定的参考借鉴加载,需要的朋友可以参考下
dicom文件dicom文件dicom文件
JPEG压缩DICOM文件格式;LittleEndian格式DICOM文件
dicom3.0文件格式医学图像15张,可作为医学图像领域研究数据。
dicom文件进行数据脱敏,可以自己更改要脱敏的信息
多帧的DICOM文件,是学习DICOM解析必备文件
C#实现的一个获取Dicom文件内部tag存储的数据。可重新编译参考。支持显式、隐式
这个是dicom的结构化报告文件数据,来源于测试数据,供sr类型数据参考