#include "widget.h"
#include "ui_widget.h"
#include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */
#include "dcmtk/dcmdata/dctk.h"
#include "dcmtk/dcmdata/dcpxitem.h"
#include "dcmtk/dcmimgle/dcmimage.h"
#include <QDebug>
uint getPixelValue(DicomImage *image,long x, long y, EP_Representation &r)
{
if (image) {
const DiPixel* pixel = image->getInterData();
if (pixel && (x < (long)image->getWidth()) && (x >= 0)
&& (y < (long)image->getHeight()) && (y >= 0)) {
r = pixel->getRepresentation();
switch (r) {
case EPR_Sint8:
case EPR_Uint8:
return *((char*)(pixel->getData()) + (y * image->getWidth() + x));
case EPR_Sint16:
case EPR_Uint16:
return *((short*)(pixel->getData()) + (y * image->getWidth() + x));
case EPR_Sint32:
case EPR_Uint32:
return *((int*)(pixel->getData()) + (y * image->getWidth() + x));
}
}
}
r = (EP_Representation)-1;
return 0;
}
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
DicomImage* dcmImage = new DicomImage("D:/dcm/dcm_rc1/57DF1DB1");
Sint16 *pixelData = (Sint16 *)(dcmImage->getOutputData(16));
for(int i=0;i<100;i++)
qDebug()<<(int)pixelData[i];
double min,max;
dcmImage->getMinMaxValues(min,max);
qDebug()<<min<<max;
const DiPixel* pixel=dcmImage->getInterData();
qDebug()<<pixel->getRepresentation();
int x=0;
int y=0;
uint data=*((short*)(pixel->getData()) + (y * dcmImage->getWidth() + x));
qDebug()<<"data is:"<<(int)data;
EP_Representation r;
uint data2=getPixelValue(dcmImage,x,y,r);
qDebug()<<"data2 is:--------------------------"<<(int)data2;
for(int i=0;i<20;i++)
{
for(int j=0;j<20;j++)
{
//uint data3=getPixelValue(dcmImage,i,j,r);
//qDebug()<<(qint16)data3;
uint data=*((short*)(pixel->getData()) + (i * dcmImage->getWidth() + j));
qDebug()<<"data is:"<<(qint16)data;
}
}
}
Widget::~Widget()
{
delete ui;
}