一、DICOM打印的两种类型
灰度图像打印:
 彩色图像打印:
通常情况下RGB类型DICOM图像包含如下的内容:
-  (0028,0010)Rows 
 图像的高度
-  (0028,0011)Columns 
 图像的宽度
-  (0028,0030)Pixel Spacing 
 图像像素间距,读取Pixel Data的时候不需要,主要用于长度测量。
-  (0028,0100)Bits Allocated 
 一个像素取样点存储时分配到的位数,一般RGB的图像,每一个颜色通道都使用8位,所以一般取值为8。对于灰度图像,如果是256级灰阶,一般就是8位。如果高于256级灰阶,一般就采用16位。
-  (0028,0101)Bits Stored 
 一个像素取样点存储时使用到的位数。比方说示例中CT影像,采用的是4K灰阶,像素值取值范围为0~4095,所以使用到的位数为12位。
-  (0028,0102)High Bit 
 最高位序号,它定义了存储点在分配的内存中的排列方式,它的值是最后一个bit的序号。如果第一个bit放在0位,那么最后一个bit为Bits Stored -1。
-  (0028,0103)Pixel Representation 
 如果这个值为0, 这表明是无符号类型,其VR类型应该为US,Unsigned Short. 如果这个值为1, 这表明为有符号类型,其VR类型应该为SS,Signed Short.
-  (0028,1050)Window Center 和 (0028,1051) Window Width 
 窗宽窗位
-  (0028,1052)Rescale Intercept 和 (0028,1053)Rescale Slope 
 用于根据像素值计算原始值,比方说,CT可以用于计算HU值。
 比方说:HU = Rescale Slope * X + Rescale Intercept.
-  PhotometricInterpretation 如是RGB图像,则其值为RGB 
-  Planar configuration (0028,0006) 定义了各个彩色通道值在Pixel Data中排列的排列方式。当此值为0的时候,它这样排列的RGBRGBRGBRGBRGB。 
 当此值为1的时候,它是这样排列的:RRRRR……GGGGG…….BBBBB。
二、组建待打印的dataset
构建待打印的dataset,图像部分相关代码如下:
if (EC_Normal == status) status = DVPSHelper::putStringValue(dataset, DCM_PhotometricInterpretation, photometric.c_str());
	if (EC_Normal == status) status = DVPSHelper::putUint16Value(dataset, DCM_SamplesPerPixel, samplesPerPixel);
	if (EC_Normal == status) status = DVPSHelper::putUint16Value(dataset, DCM_Rows, info.filmImage.height);
	if (EC_Normal == status) status = DVPSHelper::putUint16Value(dataset, DCM_Columns, info.filmImage.width);
	if (EC_Normal == status) status = DVPSHelper::putUint16Value(dataset, DCM_BitsAllocated, info.filmImage.bitStored);
	if (EC_Normal == status) status = DVPSHelper::putUint16Value(dataset, DCM_BitsStored, info.filmImage.bitStored);
	if (EC_Normal == status) status = DVPSHelper::putUint16Value(dataset, DCM_HighBit, info.filmImage.bitStored - 1);
	if (EC_Normal == status) status = DVPSHelper::putUint16Value(dataset, DCM_PixelRepresentation, 0);三、上层构建RGB图像数据
作者使用Qt,所以定义RGB888格式的QImage图像,以限定像素排列顺序为RGBRGBRGBRGBRGB
QImage print_image = image.convertToFormat(QImage::Format_RGB888);获取bits,然后供dicom图像写入。
info.filmImage.bits = print_image.bits();四、打印图像分页
根据打印的序列图像总数和布局单元格数量,计算总页数:
		m_total = m_imageItems.size() / getFilmCount();
		if (m_imageItems.size() % getFilmCount() != 0)
			++m_total;
		if (m_total < 1)
			m_total = 1;获取当前页关联图像列表:
int pageCount = getFilmCount();
	int start = (m_current -1) * pageCount;
	return m_imageItems.mid(start, pageCount);五、打印效果预览
灰度图像打印:

彩色图像打印:

 



















