X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=tools%2FclitkDicom2Image.cxx;h=51a32d15550ff3a1afe2dff199d97514e81ccbd0;hb=01a0dd7b79c5e5d5b82878d9e64dcba12891b53d;hp=1ac985e504de85c97aef1c8695a0d59cf3b84660;hpb=b7842673d15e983fde13046981c9eb0d4e4158c8;p=clitk.git diff --git a/tools/clitkDicom2Image.cxx b/tools/clitkDicom2Image.cxx index 1ac985e..51a32d1 100644 --- a/tools/clitkDicom2Image.cxx +++ b/tools/clitkDicom2Image.cxx @@ -91,16 +91,19 @@ int main(int argc, char * argv[]) series_numbers.insert(series_number); theorigin[series_number] = gdcm::ImageHelper::GetOriginValue(hreader.GetFile()); theorientation[series_number] = gdcm::ImageHelper::GetDirectionCosinesValue(hreader.GetFile()); - double n1 = theorientation[series_number][1]*theorientation[series_number][5]- - theorientation[series_number][2]*theorientation[series_number][4]; - double n2 = theorientation[series_number][3]*theorientation[series_number][2]- - theorientation[series_number][5]*theorientation[series_number][0]; - double n3 = theorientation[series_number][0]*theorientation[series_number][4]- - theorientation[series_number][1]*theorientation[series_number][3]; - double sloc = theorigin[series_number][0]*n1+ - theorigin[series_number][1]*n2+ - theorigin[series_number][2]*n3; - sliceLocations[series_number].push_back(sloc); + if (args_info.extract_series_flag) { + double n1 = theorientation[series_number][1]*theorientation[series_number][5]- + theorientation[series_number][2]*theorientation[series_number][4]; + double n2 = theorientation[series_number][3]*theorientation[series_number][2]- + theorientation[series_number][5]*theorientation[series_number][0]; + double n3 = theorientation[series_number][0]*theorientation[series_number][4]- + theorientation[series_number][1]*theorientation[series_number][3]; + double sloc = theorigin[series_number][0]*n1+ + theorigin[series_number][1]*n2+ + theorigin[series_number][2]*n3; + sliceLocations[series_number].push_back(sloc); + } else + sliceLocations[series_number].push_back(theorigin[series_number][2]); seriesFiles[series_number].push_back(input_files[i]); gdcm::Attribute<0x28, 0x100> pixel_size; @@ -236,26 +239,10 @@ int main(int argc, char * argv[]) name << *sn << "_" << args_info.output_arg; outfile = name.str(); } - //Check on transform - bool bId = true; - if (!image->GetTransform().empty()) { - for(unsigned int i=0; i<4; i++) { - for(unsigned int j=0; j<4; j++) { - double elt = image->GetTransform()[0]->GetMatrix()->GetElement(i,j); - if(i==j && elt!=1.) { - bId = false; - } - if(i!=j && elt!=0.) { - bId = false; - } - } - } - } vvImageWriter::Pointer writer = vvImageWriter::New(); writer->SetInput(image); - if(!bId) { - writer->SetSaveTransform(true); - } + if (args_info.extract_series_flag && !image->GetTransform().empty()) + writer->SetSaveTransform(true); writer->SetOutputFileName(outfile); writer->Update();