First update.

This commit is contained in:
sunwen
2023-10-09 09:29:21 +08:00
parent a434c105c0
commit 903ac2c087
56 changed files with 1044 additions and 1021 deletions

View File

@@ -16,8 +16,8 @@
using namespace std;
namespace {
double getSpacing(double * startPoint, double* endPoint, int* imageXYZ, int index){
return (endPoint[index]-startPoint[index])/(double)(imageXYZ[index])*1000.0;
float getSpacing(float * startPoint, float* endPoint, int* imageXYZ, int index){
return (endPoint[index]-startPoint[index])/(float)(imageXYZ[index])*1000.0;
}
void initialDicomFile(DcmDataset* dataset,DcmMetaInfo* metaInfo)
@@ -132,7 +132,7 @@ namespace Recon
reflectParams::imageEndpoint.getData(), XYZ, aMatrix.getData(), type);
}
void DICOMExporter::exportDCM(string path, double * startPoint, double* endPoint, int* imageXYZ,double* data, int type)
void DICOMExporter::exportDCM(string path, float * startPoint, float* endPoint, int* imageXYZ,float* data, int type)
{
long Rows = imageXYZ[0], Cols = imageXYZ[1] ,Slices = imageXYZ[2];
DcmFileFormat dcmFile;
@@ -173,17 +173,17 @@ namespace Recon
// dataset->putAndInsertString(DCM_ProtocolName, "?");
// initial spacing and position
double spacing[3]{.0,.0,.0};
float spacing[3]{.0,.0,.0};
spacing[0] = getSpacing(startPoint,endPoint,imageXYZ,0);
spacing[1] = getSpacing(startPoint,endPoint,imageXYZ,1);
spacing[2] = getSpacing(startPoint,endPoint,imageXYZ,2);
double originPosition[3] = {
endPoint[1]*1000.0,
endPoint[2]*1000.0,
endPoint[0]*1000.0,
float originPosition[3] = {
endPoint[1]*(float)1000.0,
endPoint[2]*(float)1000.0,
endPoint[0]*(float)1000.0,
};
double originLocation =endPoint[1]*1000.0;
float originLocation =endPoint[1]*1000.0;
dataset->putAndInsertString(DCM_SliceThickness, to_string(spacing[2]).data());
dataset->putAndInsertUint16(DCM_Rows, Rows);
dataset->putAndInsertUint16(DCM_Columns, Cols);
@@ -191,11 +191,11 @@ namespace Recon
dataset->putAndInsertString(DCM_PixelSpacing, spacingsBP.data());
// initial data, wwwl , Slope,Intercept
double Slope = 1, Intercept = 0 ;
float Slope = 1, Intercept = 0 ;
size_t size = Rows*Cols*Slices;
ushort* udata = new ushort[size]{0};
double min = data[0];
double max = data[0];
float min = data[0];
float max = data[0];
for (size_t i = 0; i < size; i++)
{
if (type == 0) data[i] = 1000*data[i];
@@ -204,8 +204,8 @@ namespace Recon
}
long windowCenter = min + (max-min)/2, windowWidth = max-min;
double dSlope = 1.0/(pow(2,16)/windowWidth);
double dIntercept = min;
float dSlope = 1.0/(pow(2,16)/windowWidth);
float dIntercept = min;
for (size_t i = 0; i < size; i++)
{
udata[i] = (ushort)((data[i] - min)/dSlope);