From 326db5ee4f358707ed1ad2841d37a702daead3d6 Mon Sep 17 00:00:00 2001 From: jpr Date: Mon, 12 Sep 2011 11:11:30 +0000 Subject: [PATCH] Code factorization --- Example/PcpdenseToDicom.cxx | 362 ++++++++++++------------------------ 1 file changed, 123 insertions(+), 239 deletions(-) diff --git a/Example/PcpdenseToDicom.cxx b/Example/PcpdenseToDicom.cxx index 834a345d..03612fdb 100644 --- a/Example/PcpdenseToDicom.cxx +++ b/Example/PcpdenseToDicom.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: PcpdenseToDicom.cxx,v $ Language: C++ - Date: $Date: 2011/09/06 16:08:07 $ - Version: $Revision: 1.9 $ + Date: $Date: 2011/09/12 11:11:30 $ + Version: $Revision: 1.10 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -40,12 +40,13 @@ void MakeDicomImage(unsigned short int *tabVal, int X, int Y, std::string dcmImageName, const char * patientName, int nbFrames, std::string studyUID, std::string serieUID, std::string SerieDescr, int imgNum, bool m ); -void LoadImage(std::ifstream &from, unsigned short int * ); +void LoadImage(std::ifstream &from, unsigned short int *, int multFact); -void LoadImageX2(std::ifstream &from, unsigned short int * ); +void LoadImageX2(std::ifstream &from, unsigned short int *, int multFact); void RotateImage(unsigned short int *image, unsigned short int *image2, int NX, int NY); void FlipImage (unsigned short int *image, unsigned short int *image2, int NX, int NY); +void WholeBazar (unsigned short int *image, int NX, int NY, int numberOfSlices, std::string strStudyUID, std::string serieDescr, const char* patientName, bool multiframe, bool X2, int multFact, const char *rootfilename); bool verbose; int main(int argc, char *argv[]) @@ -58,6 +59,7 @@ int main(int argc, char *argv[]) " (e.g.. : meas_MID380_DENSE_stacked_slices_aif_FID81637)", " numberOfSlices = (default : 3) ", " X2 : multiply x 2 image size ", + " multFact = (default : 1000) multiply pixel value by... ", " m :create multiframe files instead of image stacks ", " [patientname = Patient's name] ", " [verbose] [debug] ", @@ -85,6 +87,7 @@ int main(int argc, char *argv[]) const char *rootfilename = am->ArgMgrWantString("rootfilename",usage); int numberOfSlices = am->ArgMgrGetInt("numberOfSlices",3); + int multFact = am->ArgMgrGetInt("multFact",1000); const char *patientName = am->ArgMgrGetString("patientname", "Patient^Name"); if (am->ArgMgrDefined("debug")) @@ -111,11 +114,11 @@ int main(int argc, char *argv[]) std::string strSerieUID; std::string strStudyUID = GDCM_NAME_SPACE::Util::CreateUniqueUID(); - std::string dcmImageName, textFileName, patientname, serieDescr; + std::string /*dcmImageName,*/ textFileName, patientname, serieDescr; std::string deb(rootfilename); unsigned short int *image; - unsigned short int *image2; +// unsigned short int *image2; int NX, NY; @@ -140,242 +143,25 @@ int main(int argc, char *argv[]) fromEcc >> NX; fromEcc >> NY; std::cout << "NX, NY : " << NX << ", " << NY << std::endl; - } - - int mult; - if (X2) - mult=4; - else - mult=1; - - if (multiframe) { - image = new unsigned short int[NX*NY*mult*numberOfSlices]; - image2 = new unsigned short int[NX*NY*mult*numberOfSlices]; - } else { - image = new unsigned short int[NX*NY*mult]; - image2 = new unsigned short int[NX*NY*mult]; - } - - // === Ecc === - - strSerieUID = GDCM_NAME_SPACE::Util::CreateUniqueUID(); - - serieDescr = "Ecc"; - - if (!multiframe) { - for (int i=0; i> pixelValue; - image[i*NX+j] = (unsigned short int)(pixelValue * 1000.); // Why do we multiply by 1000? // JPR + image[i*NX+j] = (unsigned short int)(pixelValue * multFact); // Why do we multiply by 1000? // JPR } } } @@ -412,7 +198,7 @@ XY Dimensions 47 50 // ===================================================================================================================== -void LoadImageX2(std::ifstream &from, unsigned short int *image ) +void LoadImageX2(std::ifstream &from, unsigned short int *image, int multFact ) { // in any file ".txt" : @@ -457,7 +243,7 @@ XY Dimensions 47 50 for( i=0;i> pixelValue; - pixelValue*=1000.; // Why do we multiply by 1000? // JPR + pixelValue*=multFact; // Why do we multiply by 1000? // JPR image[debLigneNvlleImage + j+j] = image[debLigneNvlleImage + j+j +1] = image[debLigneNvlleImage + lgrLigneNvlleImage +j+j] = @@ -488,13 +274,112 @@ void FlipImage(unsigned short int *image, unsigned short int *image2, int NX, in for(int j=0;j in MakeDicomImage : dcmImageName = [" << // delete img; file->Delete(); - fileH->Delete(); + fileH->Delete(); + std::cout << "========================> out of MakeDicomImage : " << std::endl; } - // ===================================================================================================================== - -- 2.45.0