From c68bf30f0b3499ab9f3a65b2c31a47436581597d Mon Sep 17 00:00:00 2001 From: Eduardo DAVILA Date: Fri, 7 Feb 2020 16:28:26 +0100 Subject: [PATCH] #3221 creaRigidRegistration Feature New Normal - vtk8itk4wx3-mingw64 --- .../bbs/boxes/CompareImagesWidget.bbg | 167 ++++++++++-------- .../bbs/boxes/CompareImagesWidget.bbs | 79 +++++---- .../src/bbPackRecalageImageConvolution.cxx | 7 +- .../src/bbPackRecalageReSlicerBox.cxx | 16 +- .../src/bbPackRecalageTransparencyBox.cxx | 14 +- lib/Convolution.cxx | 9 +- lib/Transformer.cxx | 1 + lib/Transparency.cxx | 132 +++++++------- lib/Transparency.h | 17 -- 9 files changed, 225 insertions(+), 217 deletions(-) diff --git a/PackRecalage/bbs/boxes/CompareImagesWidget.bbg b/PackRecalage/bbs/boxes/CompareImagesWidget.bbg index c1d3c85..6271426 100644 --- a/PackRecalage/bbs/boxes/CompareImagesWidget.bbg +++ b/PackRecalage/bbs/boxes/CompareImagesWidget.bbg @@ -1,6 +1,6 @@ # ---------------------------------- # - BBTKGEditor v 1.4 BBG BlackBox Diagram file -# - /home/davila/Creatis/All/creatools_source/creaRigidRegistration/PackRecalage/bbs/boxes/CompareImagesWidget.bbg +# - /home/davila/Creatis/C8/creatools_source/creaRigidRegistration/PackRecalage/bbs/boxes/CompareImagesWidget.bbg # ---------------------------------- APP_START @@ -28,18 +28,18 @@ COMPLEX_PORT WinTitle 452.869978:45.181751:-900.000000 FIN_COMPLEX_PORT -BOXES:36 +BOXES:37 BOX PackRecalage:ImageRecalageProperties:properties ISEXEC:FALSE -611.308256:-6.931722:-900.000000 -682.483256:-16.931722:-900.000000 +539.826193:-452.173474:-900.000000 +595.376193:-462.173474:-900.000000 FIN_BOX BOX wx:Slider:sdrZ ISEXEC:FALSE -567.054652:-61.454750:-900.000000 -618.454652:-71.454750:-900.000000 +150.457366:-521.645863:-900.000000 +201.857366:-531.645863:-900.000000 PORT Min:"0" PORT @@ -50,8 +50,8 @@ FIN_BOX BOX wx:Slider:sdrF ISEXEC:FALSE -829.057291:-86.758889:-900.000000 -880.457291:-96.758889:-900.000000 +239.873940:-516.699316:-900.000000 +291.273940:-526.699316:-900.000000 PORT In:"0" PORT @@ -66,22 +66,22 @@ FIN_BOX BOX wx:CheckBox:checkF ISEXEC:FALSE -864.894336:-109.592108:-900.000000 -910.469336:-119.592108:-900.000000 +333.547054:-512.792558:-900.000000 +371.197054:-522.792558:-900.000000 PORT In:"True" FIN_BOX BOX std:MultipleInputs:multF ISEXEC:FALSE -873.672975:-258.351155:-900.000000 -919.247975:-268.351155:-900.000000 +217.666169:-629.290083:-900.000000 +256.666169:-639.290083:-900.000000 FIN_BOX BOX wx:Slider:colorLevel ISEXEC:FALSE -626.588388:-79.223450:-900.000000 -677.988388:-89.223450:-900.000000 +603.292740:-550.814817:-900.000000 +654.692740:-560.814817:-900.000000 PORT Min:"0" PORT @@ -92,8 +92,8 @@ FIN_BOX BOX wx:Slider:windowLevel ISEXEC:FALSE -697.550959:-84.063593:-900.000000 -748.950959:-94.063593:-900.000000 +674.847946:-558.490407:-900.000000 +726.247946:-568.490407:-900.000000 PORT Min:"0" PORT @@ -104,20 +104,20 @@ FIN_BOX BOX std:MultipleInputs:multLevels ISEXEC:FALSE -288.287844:-125.896361:-900.000000 -333.862844:-135.896361:-900.000000 +679.603024:-599.665695:-900.000000 +723.553024:-609.665695:-900.000000 FIN_BOX BOX PackRecalage:CheckBoardBox:cbb ISEXEC:FALSE -558.230487:-599.874244:-900.000000 -603.805487:-609.874244:-900.000000 +536.125779:-738.028671:-900.000000 +576.300779:-748.028671:-900.000000 FIN_BOX BOX wx:Slider:sdr ISEXEC:FALSE -655.843588:-494.766848:-900.000000 -707.243588:-504.766848:-900.000000 +616.765621:-647.526172:-900.000000 +668.165621:-657.526172:-900.000000 PORT In:"14" PORT @@ -128,8 +128,8 @@ FIN_BOX BOX wx:Slider:sdr2 ISEXEC:FALSE -714.326943:-493.179468:-900.000000 -765.726943:-503.179468:-900.000000 +704.458770:-649.096607:-900.000000 +755.858770:-659.096607:-900.000000 PORT In:"14" PORT @@ -140,36 +140,36 @@ FIN_BOX BOX wx:LayoutSplit:checkerBoard ISEXEC:FALSE -644.846530:-650.309000:-900.000000 -690.421530:-660.309000:-900.000000 +544.019687:-789.486642:-900.000000 +588.719687:-799.486642:-900.000000 PORT Proportion:"80" FIN_BOX BOX wx:LayoutLine:ly ISEXEC:FALSE -697.847204:-530.358318:-900.000000 -755.407204:-540.358318:-900.000000 +643.374887:-681.933461:-900.000000 +700.934887:-691.933461:-900.000000 FIN_BOX BOX creaMaracasVisu:ViewerNV:viewerCH ISEXEC:FALSE -530.879919:-624.359326:-900.000000 -591.519919:-634.359326:-900.000000 +506.801576:-760.145392:-900.000000 +570.521576:-770.145392:-900.000000 PORT nTypeView:"0" FIN_BOX BOX PackRecalage:TransparencyBox:trans ISEXEC:FALSE -174.200863:-765.830614:-900.000000 -219.775863:-775.830614:-900.000000 +237.984820:-780.451058:-900.000000 +279.809820:-790.451058:-900.000000 FIN_BOX BOX wx:Slider:sdrP ISEXEC:FALSE -324.954367:-704.406667:-900.000000 -376.354367:-714.406667:-900.000000 +334.879676:-745.930920:-900.000000 +386.279676:-755.930920:-900.000000 PORT In:"50" PORT @@ -182,58 +182,58 @@ FIN_BOX BOX creaMaracasVisu:ViewerNV:transView ISEXEC:FALSE -164.282997:-798.714564:-900.000000 -224.922997:-808.714564:-900.000000 +209.250725:-814.919150:-900.000000 +272.970725:-824.919150:-900.000000 PORT nTypeView:"0" FIN_BOX BOX wx:LayoutSplit:transparency ISEXEC:FALSE -205.109758:-835.113298:-900.000000 -250.684758:-845.113298:-900.000000 +235.695915:-845.443722:-900.000000 +279.420915:-855.443722:-900.000000 PORT Proportion:"80" FIN_BOX BOX std:MultipleInputs:mult2 ISEXEC:FALSE -146.357541:-665.225031:-900.000000 -191.932541:-675.225031:-900.000000 +189.299695:-705.331383:-900.000000 +228.474695:-715.331383:-900.000000 FIN_BOX BOX std:MultipleInputs:mult3 ISEXEC:FALSE -401.536745:-634.900546:-900.000000 -447.111745:-644.900546:-900.000000 +386.547502:-726.659017:-900.000000 +425.722502:-736.659017:-900.000000 FIN_BOX BOX std:MultipleInputs:mult4 ISEXEC:FALSE 179.123700:-731.703455:-900.000000 -224.698700:-741.703455:-900.000000 +218.298700:-741.703455:-900.000000 FIN_BOX BOX wx:LayoutTab:tabs ISEXEC:FALSE -191.519819:-874.211466:-900.000000 -249.079819:-884.211466:-900.000000 +236.892661:-877.452383:-900.000000 +294.452661:-887.452383:-900.000000 PORT Orientation:V FIN_BOX BOX wx:LayoutLine:tools ISEXEC:FALSE -771.358267:-334.065430:-900.000000 -828.918267:-344.065430:-900.000000 +459.974173:-652.062016:-900.000000 +517.534173:-662.062016:-900.000000 PORT WinTitle:"Appearance" FIN_BOX BOX wx:LayoutSplit:convolTools ISEXEC:FALSE -868.493941:-177.072226:-900.000000 -914.068941:-187.072226:-900.000000 +375.675088:-586.605666:-900.000000 +417.925088:-596.605666:-900.000000 PORT Orientation:"H" PORT @@ -243,7 +243,7 @@ BOX wx:LayoutSplit:window2 ISEXEC:FALSE 282.177476:-902.826135:-900.000000 -327.752476:-912.826135:-900.000000 +321.652476:-912.826135:-900.000000 PORT Orientation:H PORT @@ -252,42 +252,42 @@ FIN_BOX BOX vtk:vtkImageDataPointerRelay:Box56 ISEXEC:FALSE -118.565004:15.062216:-900.000000 -189.740004:5.062216:-900.000000 +278.280926:-370.917928:-900.000000 +330.455926:-380.917928:-900.000000 FIN_BOX BOX vtk:vtkImageDataPointerRelay:Box59 ISEXEC:FALSE -289.953516:7.294430:-900.000000 -361.128516:-2.705570:-900.000000 +464.846105:-417.390719:-900.000000 +517.021105:-427.390719:-900.000000 FIN_BOX BOX wx:LayoutTab:Box61 ISEXEC:FALSE -403.420085:-702.995108:-900.000000 -460.980085:-712.995108:-900.000000 +434.481239:-727.433245:-900.000000 +492.041239:-737.433245:-900.000000 FIN_BOX BOX creaMaracasVisu:ViewerNV:Box65 ISEXEC:FALSE -419.572796:-801.103027:-900.000000 -480.212796:-811.103027:-900.000000 +344.018911:-827.232923:-900.000000 +407.738911:-837.232923:-900.000000 PORT nTypeView:0 FIN_BOX BOX creaMaracasVisu:ViewerNV:Box66 ISEXEC:FALSE -497.442434:-799.958959:-900.000000 -558.082434:-809.958959:-900.000000 +421.497172:-830.459865:-900.000000 +485.217172:-840.459865:-900.000000 PORT nTypeView:0 FIN_BOX BOX wx:LayoutLine:Box67 ISEXEC:FALSE -428.693407:-832.025005:-900.000000 -486.253407:-842.025005:-900.000000 +344.632115:-865.041850:-900.000000 +402.192115:-875.041850:-900.000000 PORT Orientation:H PORT @@ -296,34 +296,40 @@ FIN_BOX BOX std:MultipleInputs:Box68 ISEXEC:FALSE -625.007956:-758.235235:-900.000000 -670.582956:-768.235235:-900.000000 +419.817379:-784.162573:-900.000000 +459.517379:-794.162573:-900.000000 FIN_BOX BOX PackRecalage:CompareImagesSwitcherWidget:Box69 ISEXEC:FALSE --91.678462:-684.794791:-900.000000 --20.503462:-694.794791:-900.000000 +137.263160:-780.713436:-900.000000 +195.013160:-790.713436:-900.000000 FIN_BOX BOX PackRecalage:CompareImagesWidget_base_2Dt_A:Box70 ISEXEC:FALSE --151.333352:-530.748508:-900.000000 --80.158352:-540.748508:-900.000000 +129.758517:-665.244627:-900.000000 +191.783517:-675.244627:-900.000000 FIN_BOX BOX std:MultipleInputs:Box71 ISEXEC:FALSE --194.872618:-467.078336:-900.000000 --149.297618:-477.078336:-900.000000 +105.932142:-617.753110:-900.000000 +145.632142:-627.753110:-900.000000 FIN_BOX BOX PackRecalage:CompareImagesWidget_base_2Dt_B:Box72 ISEXEC:FALSE -24.864793:-523.045609:-900.000000 -96.039793:-533.045609:-900.000000 +256.073649:-670.863892:-900.000000 +317.773649:-680.863892:-900.000000 FIN_BOX -CONNECTIONS:80 +BOX +creaMaracasVisu:SetPosition:Box39 +ISEXEC:FALSE +426.711165:-857.651354:-900.000000 +463.261165:-867.651354:-900.000000 +FIN_BOX +CONNECTIONS:83 CONNECTION properties:LengthZ:sdrZ:Max NumberOfControlPoints:0 @@ -445,9 +451,6 @@ CONNECTION sdrF:Widget:convolTools:Widget1 NumberOfControlPoints:0 CONNECTION -window2:Widget:Widget:Widget -NumberOfControlPoints:0 -CONNECTION sdrZ:Widget:tools:Widget1 NumberOfControlPoints:0 CONNECTION @@ -564,4 +567,16 @@ NumberOfControlPoints:0 CONNECTION sdrZ:Out:Box72:SliceZ NumberOfControlPoints:0 +CONNECTION +window2:Widget:Widget:Widget +NumberOfControlPoints:0 +CONNECTION +Box65:Point:Box39:Point +NumberOfControlPoints:0 +CONNECTION +Box66:wxVtkBaseView1:Box39:wxVtkBaseView +NumberOfControlPoints:0 +CONNECTION +Box65:BoxChange:Box39:BoxExecute +NumberOfControlPoints:0 APP_END diff --git a/PackRecalage/bbs/boxes/CompareImagesWidget.bbs b/PackRecalage/bbs/boxes/CompareImagesWidget.bbs index a32cc73..94607d9 100644 --- a/PackRecalage/bbs/boxes/CompareImagesWidget.bbs +++ b/PackRecalage/bbs/boxes/CompareImagesWidget.bbs @@ -1,6 +1,6 @@ # ---------------------------------- # - BBTKGEditor v 1.4 BBS BlackBox Script (Complex Box) -# - /home/davila/Creatis/All/creatools_source/creaRigidRegistration/PackRecalage/bbs/boxes/CompareImagesWidget.bbs +# - /home/davila/Creatis/C8/creatools_source/creaRigidRegistration/PackRecalage/bbs/boxes/CompareImagesWidget.bbs # ---------------------------------- include std @@ -18,116 +18,118 @@ description "creatisRecalage" category "example" -new ImageRecalageProperties properties +new PackRecalage:ImageRecalageProperties properties -new Slider sdrZ +new wx:Slider sdrZ set sdrZ.Min "0" set sdrZ.ReactiveOnTrack "1" set sdrZ.Title "Z for slice" -new Slider sdrF +new wx:Slider sdrF set sdrF.In "0" set sdrF.Max "100" set sdrF.Min "0" set sdrF.ReactiveOnTrack "1" set sdrF.Title "Convolution Factor" -new CheckBox checkF +new wx:CheckBox checkF set checkF.In "True" -new MultipleInputs multF +new std:MultipleInputs multF -new Slider colorLevel +new wx:Slider colorLevel set colorLevel.Min "0" set colorLevel.ReactiveOnTrack "true" set colorLevel.Title "Color Level" -new Slider windowLevel +new wx:Slider windowLevel set windowLevel.Min "0" set windowLevel.ReactiveOnTrack "true" set windowLevel.Title "Window Level" -new MultipleInputs multLevels +new std:MultipleInputs multLevels -new CheckBoardBox cbb +new PackRecalage:CheckBoardBox cbb -new Slider sdr +new wx:Slider sdr set sdr.In "14" set sdr.Max "50" set sdr.ReactiveOnTrack "1" -new Slider sdr2 +new wx:Slider sdr2 set sdr2.In "14" set sdr2.Max "50" set sdr2.ReactiveOnTrack "1" -new LayoutSplit checkerBoard +new wx:LayoutSplit checkerBoard set checkerBoard.Proportion "80" -new LayoutLine ly +new wx:LayoutLine ly -new ViewerNV viewerCH +new creaMaracasVisu:ViewerNV viewerCH set viewerCH.nTypeView "0" -new TransparencyBox trans +new PackRecalage:TransparencyBox trans -new Slider sdrP +new wx:Slider sdrP set sdrP.In "50" set sdrP.Max "100" set sdrP.Min "0" set sdrP.ReactiveOnTrack "true" -new ViewerNV transView +new creaMaracasVisu:ViewerNV transView set transView.nTypeView "0" -new LayoutSplit transparency +new wx:LayoutSplit transparency set transparency.Proportion "80" -new MultipleInputs mult2 +new std:MultipleInputs mult2 -new MultipleInputs mult3 +new std:MultipleInputs mult3 -new MultipleInputs mult4 +new std:MultipleInputs mult4 -new LayoutTab tabs +new wx:LayoutTab tabs set tabs.Orientation V -new LayoutLine tools +new wx:LayoutLine tools set tools.WinTitle "Appearance" -new LayoutSplit convolTools +new wx:LayoutSplit convolTools set convolTools.Orientation "H" set convolTools.Proportion "80" -new LayoutSplit window2 +new wx:LayoutSplit window2 set window2.Orientation H set window2.Proportion "25" -new vtkImageDataPointerRelay Box56 +new vtk:vtkImageDataPointerRelay Box56 -new vtkImageDataPointerRelay Box59 +new vtk:vtkImageDataPointerRelay Box59 -new LayoutTab Box61 +new wx:LayoutTab Box61 -new ViewerNV Box65 +new creaMaracasVisu:ViewerNV Box65 set Box65.nTypeView 0 -new ViewerNV Box66 +new creaMaracasVisu:ViewerNV Box66 set Box66.nTypeView 0 -new LayoutLine Box67 +new wx:LayoutLine Box67 set Box67.Orientation H set Box67.WinTitle "Parallel" -new MultipleInputs Box68 +new std:MultipleInputs Box68 -new CompareImagesSwitcherWidget Box69 +new PackRecalage:CompareImagesSwitcherWidget Box69 -new CompareImagesWidget_base_2Dt_A Box70 +new PackRecalage:CompareImagesWidget_base_2Dt_A Box70 -new MultipleInputs Box71 +new std:MultipleInputs Box71 -new CompareImagesWidget_base_2Dt_B Box72 +new PackRecalage:CompareImagesWidget_base_2Dt_B Box72 + +new creaMaracasVisu:SetPosition Box39 connect properties.LengthZ sdrZ.Max @@ -206,6 +208,9 @@ connect checkF.Out Box72.ConvolutionOnOff connect sdrF.Out Box72.ConvolutionFactor connect multF.BoxChange Box72.BoxExecute connect sdrZ.Out Box72.SliceZ +connect Box65.Point Box39.Point +connect Box66.wxVtkBaseView1 Box39.wxVtkBaseView +connect Box65.BoxChange Box39.BoxExecute # Complex input ports input In2 Box59.In " " diff --git a/PackRecalage/src/bbPackRecalageImageConvolution.cxx b/PackRecalage/src/bbPackRecalageImageConvolution.cxx index 8f45bed..f062a1c 100644 --- a/PackRecalage/src/bbPackRecalageImageConvolution.cxx +++ b/PackRecalage/src/bbPackRecalageImageConvolution.cxx @@ -40,7 +40,7 @@ void ImageConvolution::Process() convolution->setOn(bbGetInputOn()); convolution->Run(); bbSetOutputOut(convolution->getImage()); - } + }// if } void ImageConvolution::bbUserSetDefaultValues() @@ -55,9 +55,10 @@ void ImageConvolution::bbUserInitializeProcessing() { convolution = new Convolution(); } + void ImageConvolution::bbUserFinalizeProcessing() { delete convolution; } -} -// EO namespace bbPackRecalage + +}// EO namespace bbPackRecalage diff --git a/PackRecalage/src/bbPackRecalageReSlicerBox.cxx b/PackRecalage/src/bbPackRecalageReSlicerBox.cxx index c501128..e5b29da 100644 --- a/PackRecalage/src/bbPackRecalageReSlicerBox.cxx +++ b/PackRecalage/src/bbPackRecalageReSlicerBox.cxx @@ -93,8 +93,8 @@ void ReSlicerBox::Process() { image->CenterImageOn(); } - - double tmpbackInfo[19]; + image->Update(); + double tmpbackInfo[19]; GetBackInfo(tmpbackInfo,bbGetInputTransform()->GetMatrix(),bbGetInputOrigin() ); if ( CompareBackInfo(backInfoA,tmpbackInfo)==false ) @@ -129,7 +129,7 @@ void ReSlicerBox::Process() bbGetInputIn()->GetSpacing(spc); imageResult->SetOutputSpacing( spc ); imageResult->SetOutputOrigin( 0,0,0 ); - + imageResult->Update(); bbSetOutputOut( imageResult->GetOutput() ); if (bbGetInputTransform()!=NULL) @@ -178,16 +178,16 @@ void ReSlicerBox::bbUserInitializeProcessing() // Here does nothing // but this is where you should allocate the internal/output pointers // if any - image = vtkImageChangeInformation::New(); - slicer =vtkImageReslice::New(); + image = vtkImageChangeInformation::New(); + slicer = vtkImageReslice::New(); imageResult = vtkImageChangeInformation::New(); } void ReSlicerBox::bbUserFinalizeProcessing() { - image->Delete(); - slicer->Delete(); - imageResult->Delete(); + image -> Delete(); + slicer -> Delete(); + imageResult -> Delete(); } } diff --git a/PackRecalage/src/bbPackRecalageTransparencyBox.cxx b/PackRecalage/src/bbPackRecalageTransparencyBox.cxx index a159154..4490a12 100644 --- a/PackRecalage/src/bbPackRecalageTransparencyBox.cxx +++ b/PackRecalage/src/bbPackRecalageTransparencyBox.cxx @@ -37,9 +37,9 @@ void TransparencyBox::Process() transparency->setImage2(bbGetInputIn2()); transparency->setPercent(bbGetInputPercent()); transparency->calculateImage(); - bbSetOutputOut(transparency->getImage()); } + void TransparencyBox::bbUserSetDefaultValues() { bbSetInputIn1(NULL); @@ -47,20 +47,20 @@ void TransparencyBox::bbUserSetDefaultValues() bbSetInputPercent(-1); bbSetOutputOut(NULL); } + void TransparencyBox::bbUserInitializeProcessing() { transparency = new Transparency(); } + void TransparencyBox::bbUserFinalizeProcessing() -{ - +{ // THE FINALIZATION METHOD BODY : // Here does nothing // but this is where you should desallocate the internal/output pointers -// if any - -} +// if any } -// EO namespace bbPackRecalage + +}// EO namespace bbPackRecalage diff --git a/lib/Convolution.cxx b/lib/Convolution.cxx index 810ec96..6014ecd 100644 --- a/lib/Convolution.cxx +++ b/lib/Convolution.cxx @@ -32,9 +32,9 @@ //------------------------------------------------------------ Convolution::Convolution() { - _image=NULL; - _convolve = vtkImageConvolve::New(); - _cast = vtkImageCast::New(); + _image = NULL; + _convolve = vtkImageConvolve::New(); + _cast = vtkImageCast::New(); } /* @@ -65,7 +65,6 @@ void Convolution::setImage(vtkImageData *image) void Convolution::setFactor(double factor) { - // _factor = (factor/100.0)*5.0; _factor = factor; } @@ -99,5 +98,5 @@ void Convolution::Run() #endif _cast->SetOutputScalarType(_image->GetScalarType()); _cast->Update(); - } + } // if _on } diff --git a/lib/Transformer.cxx b/lib/Transformer.cxx index 66763d6..0df52af 100644 --- a/lib/Transformer.cxx +++ b/lib/Transformer.cxx @@ -111,6 +111,7 @@ void Transformer::SetScaleZ(double scaleZ) */ vtkTransform *Transformer::GetResult() { + _transform->Update(); return _transform; } diff --git a/lib/Transparency.cxx b/lib/Transparency.cxx index 8749685..1855283 100644 --- a/lib/Transparency.cxx +++ b/lib/Transparency.cxx @@ -33,11 +33,11 @@ //------------------------------------------------------------ Transparency::Transparency() { - _image1=NULL; - _image2=NULL; - _percent=0; - _newImage = NULL; - _processed=false; + _image1 = NULL; + _image2 = NULL; + _percent = 0; + _newImage = NULL; + _processed = false; } /* @@ -52,9 +52,10 @@ Transparency::~Transparency() //------------------------------------------------------------ void Transparency::calculateImage() { - +printf("EED Transparency::calculateImage Start\n"); if(_image1!=NULL && _image2!=NULL) { +printf("EED Transparency::calculateImage 1\n"); // IMAGE 1 @@ -62,30 +63,25 @@ void Transparency::calculateImage() _image1->GetSpacing(spcImg1); _image1->GetExtent(extImg1); _type = _image1->GetScalarType(); - // The Z dimension is 1 for a 2D image dimImg1[0] = extImg1[1] - extImg1[0]+1; dimImg1[1] = extImg1[3] - extImg1[2]+1; dimImg1[2] = 1; - //IMAGE 2 - // Information from image2 _image2->GetSpacing(spcImg2); _image2->GetExtent(extImg2); - // The Z dimension is 1 for a 2D image dimImg2[0] = extImg2[1] - extImg2[0]+1; dimImg2[1] = extImg2[3] - extImg2[2]+1; dimImg2[2] = 1; - long numPixelsImg1 = dimImg1[0]*dimImg1[1]; - long numPixelsImg2 = dimImg2[0]*dimImg2[1]; - + long numPixelsImg2 = dimImg2[0]*dimImg2[1]; double factorX = 1; double factorY = 1; vtkImageResample *resample = vtkImageResample::New(); vtkImageData *result; +printf("EED Transparency::calculateImage 2\n"); if(numPixelsImg1SetAxisMagnificationFactor(0,factorX); resample->SetAxisMagnificationFactor(1,factorY); resample->SetInformationInput(_image2); - initialize(dimImg2, spcImg2); //EED 2017-01-01 Migration VTK7 #if VTK_MAJOR_VERSION <= 5 @@ -107,7 +102,7 @@ void Transparency::calculateImage() #else resample->Update(); #endif - +printf("EED Transparency::calculateImage 3\n"); result = resample->GetOutput(); //EED 2017-01-01 Migration VTK7 #if VTK_MAJOR_VERSION <= 5 @@ -116,10 +111,8 @@ void Transparency::calculateImage() //... #endif createImage(result,_image2,dimImg2[0],dimImg2[1]); - - } //if - else if (numPixelsImg1>numPixelsImg2) - { + } else if (numPixelsImg1>numPixelsImg2) { +printf("EED Transparency::calculateImage 4\n"); //EED 2017-01-01 Migration VTK7 #if VTK_MAJOR_VERSION <= 5 resample->SetInput(_image2); @@ -131,9 +124,7 @@ void Transparency::calculateImage() resample->SetAxisMagnificationFactor(0,factorX); resample->SetAxisMagnificationFactor(1,factorY); resample->SetInformationInput(_image1); - initialize(dimImg1, spcImg1); - //EED 2017-01-01 Migration VTK7 #if VTK_MAJOR_VERSION <= 5 // ... @@ -148,11 +139,11 @@ void Transparency::calculateImage() #else result->Modified(); #endif - +printf("EED Transparency::calculateImage 4.1\n"); createImage(_image1,result,dimImg1[0],dimImg1[1]); - } // else if - else - { +printf("EED Transparency::calculateImage 4.2\n"); + } else { +printf("EED Transparency::calculateImage 5\n"); //If both images have the same number of pixels, the resultant image will have the //properties of the first image. //EED 2017-01-01 Migration VTK7 @@ -173,23 +164,23 @@ void Transparency::calculateImage() #else resample->Update(); #endif - result = resample->GetOutput(); - //EED 2017-01-01 Migration VTK7 #if VTK_MAJOR_VERSION <= 5 result->Update(); #else result->Modified(); #endif - createImage(_image1,result,dimImg1[0],dimImg1[1]); - +printf("EED Transparency::calculateImage 6\n"); } //else - resample->Delete(); _processed=true; +printf("EED Transparency::calculateImage 7\n"); } + +printf("EED Transparency::calculateImage End\n"); + } void Transparency::initialize(int dimensions[], double spacing[]) @@ -206,61 +197,64 @@ void Transparency::initialize(int dimensions[], double spacing[]) #else _newImage->AllocateScalars(_type,1); #endif - - } void Transparency::createImage(vtkImageData *img1, vtkImageData *img2, int sizeX, int sizeY) { +printf("EED Transparency::createImage Start\n"); // int i, j; EED ??? - if(_type == VTK_CHAR) { +printf("EED Transparency::createImage 1\n"); //POINTERS: - char* dataImagePointer1 = NULL; - char* dataImagePointer2 = NULL; - char* dataImageResultPointer = NULL; - + char* dataImagePointer1 = NULL; + char* dataImagePointer2 = NULL; + char* dataImageResultPointer = NULL; createImageByType(dataImagePointer1, dataImagePointer2, dataImageResultPointer, img1, img2, sizeX, sizeY); } else if(_type == VTK_SIGNED_CHAR) { +printf("EED Transparency::createImage 2\n"); //POINTERS: - signed char* dataImagePointer1 = NULL; - signed char* dataImagePointer2 = NULL; + signed char* dataImagePointer1 = NULL; + signed char* dataImagePointer2 = NULL; signed char* dataImageResultPointer = NULL; createImageByType(dataImagePointer1, dataImagePointer2, dataImageResultPointer, img1, img2, sizeX, sizeY); } else if(_type == VTK_UNSIGNED_CHAR) { +printf("EED Transparency::createImage 3\n"); //POINTERS: - unsigned char* dataImagePointer1 = NULL; - unsigned char* dataImagePointer2 = NULL; - unsigned char* dataImageResultPointer = NULL; + unsigned char* dataImagePointer1 = NULL; + unsigned char* dataImagePointer2 = NULL; + unsigned char* dataImageResultPointer = NULL; createImageByType(dataImagePointer1, dataImagePointer2, dataImageResultPointer, img1, img2, sizeX, sizeY); } else if(_type == VTK_SHORT) { +printf("EED Transparency::createImage 4\n"); //POINTERS: - short* dataImagePointer1 = NULL; - short* dataImagePointer2 = NULL; - short* dataImageResultPointer = NULL; + short* dataImagePointer1 = NULL; + short* dataImagePointer2 = NULL; + short* dataImageResultPointer = NULL; createImageByType(dataImagePointer1, dataImagePointer2, dataImageResultPointer, img1, img2, sizeX, sizeY); } else if(_type == VTK_UNSIGNED_SHORT) { +printf("EED Transparency::createImage 5\n"); //POINTERS: - unsigned short* dataImagePointer1 = NULL; - unsigned short* dataImagePointer2 = NULL; - unsigned short* dataImageResultPointer = NULL; + unsigned short* dataImagePointer1 = NULL; + unsigned short* dataImagePointer2 = NULL; + unsigned short* dataImageResultPointer = NULL; createImageByType(dataImagePointer1, dataImagePointer2, dataImageResultPointer, img1, img2, sizeX, sizeY); } else if(_type == VTK_INT) { +printf("EED Transparency::createImage 6\n"); //POINTERS: int* dataImagePointer1 = NULL; int* dataImagePointer2 = NULL; @@ -270,6 +264,7 @@ void Transparency::createImage(vtkImageData *img1, vtkImageData *img2, int sizeX } else if(_type == VTK_UNSIGNED_INT) { +printf("EED Transparency::createImage 7\n"); //POINTERS: unsigned int* dataImagePointer1 = NULL; unsigned int* dataImagePointer2 = NULL; @@ -279,6 +274,7 @@ void Transparency::createImage(vtkImageData *img1, vtkImageData *img2, int sizeX } else if(_type == VTK_LONG) { +printf("EED Transparency::createImage 8\n"); //POINTERS: long* dataImagePointer1 = NULL; long* dataImagePointer2 = NULL; @@ -288,28 +284,31 @@ void Transparency::createImage(vtkImageData *img1, vtkImageData *img2, int sizeX } else if(_type == VTK_UNSIGNED_LONG) { +printf("EED Transparency::createImage 9\n"); //POINTERS: - unsigned long* dataImagePointer1 = NULL; - unsigned long* dataImagePointer2 = NULL; - unsigned long* dataImageResultPointer = NULL; + unsigned long* dataImagePointer1 = NULL; + unsigned long* dataImagePointer2 = NULL; + unsigned long* dataImageResultPointer = NULL; createImageByType(dataImagePointer1, dataImagePointer2, dataImageResultPointer, img1, img2, sizeX, sizeY); } else if(_type == VTK_FLOAT) { +printf("EED Transparency::createImage 10\n"); //POINTERS: - float* dataImagePointer1 = NULL; - float* dataImagePointer2 = NULL; - float* dataImageResultPointer = NULL; + float* dataImagePointer1 = NULL; + float* dataImagePointer2 = NULL; + float* dataImageResultPointer = NULL; createImageByType(dataImagePointer1, dataImagePointer2, dataImageResultPointer, img1, img2, sizeX, sizeY); } else if(_type == VTK_DOUBLE) { +printf("EED Transparency::createImage 11\n"); //POINTERS: - double* dataImagePointer1 = NULL; - double* dataImagePointer2 = NULL; - double* dataImageResultPointer = NULL; + double* dataImagePointer1 = NULL; + double* dataImagePointer2 = NULL; + double* dataImageResultPointer = NULL; createImageByType(dataImagePointer1, dataImagePointer2, dataImageResultPointer, img1, img2, sizeX, sizeY); } @@ -320,31 +319,36 @@ void Transparency::createImage(vtkImageData *img1, vtkImageData *img2, int sizeX #else _newImage->Modified(); #endif - - +printf("EED Transparency::createImage End\n"); } template void Transparency::createImageByType(T* dataImagePointer1, T* dataImagePointer2, T* dataImageResultPointer, vtkImageData *img1, vtkImageData *img2, int sizeX, int sizeY) { +printf("EED Transparency::createImageByType Start %d %d\n", sizeX, sizeY); int i, j; - dataImagePointer1 = (T*) img1->GetScalarPointer(0,0,0); dataImagePointer2 = (T*) img2->GetScalarPointer(0,0,0); dataImageResultPointer = (T*) _newImage->GetScalarPointer(0,0,0); +printf("EED Transparency::createImageByType 0 %d %d\n", sizeX, sizeY); for(i = 0; i < sizeX; i++) { for(j = 0; j < sizeY; j++) { +printf("EED Transparency::createImageByType 2 %d %d\n", sizeX, sizeY); dataImagePointer1 = (T*)img1->GetScalarPointer(i,j,0); +printf("EED Transparency::createImageByType 3 %d %d\n", sizeX, sizeY); dataImagePointer2 = (T*)img2->GetScalarPointer(i,j,0); +printf("EED Transparency::createImageByType 4 %d %d\n", sizeX, sizeY); dataImageResultPointer = (T*)_newImage->GetScalarPointer(i,j,0); - +printf("EED Transparency::createImageByType 5 %d %d\n", sizeX, sizeY); *dataImageResultPointer = (T)*dataImagePointer1*_percent + (T)*dataImagePointer2*(1-_percent); - } - } +printf("EED Transparency::createImageByType 6 %d %d\n", sizeX, sizeY); + } // for h + } // for i +printf("EED Transparency::createImageByType End\n"); } - + /* * Get new image */ diff --git a/lib/Transparency.h b/lib/Transparency.h index 3c97c2e..25f55f8 100644 --- a/lib/Transparency.h +++ b/lib/Transparency.h @@ -36,58 +36,41 @@ class Transparency public: Transparency(); ~Transparency(); - //Calculate the new image and save it in the attribute image void calculateImage(); - //Gets the result vtkImageData* getImage(); - void setImage1(vtkImageData *image); - void setImage2(vtkImageData *image); - void setPercent(int percent); - //Initialize newImage points void initialize(int dimensions[], double spacing[]); - //Constructs a new transparent image void createImage(vtkImageData *img1, vtkImageData *img2, int sizeX, int sizeY); - //Template for constructing the image by image type template void createImageByType(T* dataImagePointer1, T* dataImagePointer2, T* dataImageResultPointer, vtkImageData *img1, vtkImageData *img2, int sizeX, int sizeY); // --- Atributes --- // private: - bool _processed; - int _type; - vtkImageData *_image1; - vtkImageData *_image2; - //Resulting image vtkImageData *_newImage; - //Percent of transparency for the second image double _percent; - // Image 1 extent (iniX, finX, iniY, finY, iniZ, finZ) int extImg1[6]; // Dimensionality image 1 int dimImg1[3]; // Image 1 spacing double spcImg1[3]; - // Image 2 extent (iniX, finX, iniY, finY, iniZ, finZ) int extImg2[6]; // Dimensionality image 2 int dimImg2[3]; // Image 2 spacing double spcImg2[3]; - }; -- 2.47.1