From: eduardo.davila@creatis.insa-lyon.fr Date: Fri, 22 Nov 2024 16:05:55 +0000 (+0100) Subject: add options to convolution kerner 3x3x3 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=refs%2Fheads%2Fvtk9itk5wx3-macos;p=creaRigidRegistration.git add options to convolution kerner 3x3x3 --- diff --git a/PackRecalage/bbs/boxes/CompareImagesSwitcherWidget_3Dp.bbg b/PackRecalage/bbs/boxes/CompareImagesSwitcherWidget_3Dp.bbg index fd05a8e..5529ef6 100644 --- a/PackRecalage/bbs/boxes/CompareImagesSwitcherWidget_3Dp.bbg +++ b/PackRecalage/bbs/boxes/CompareImagesSwitcherWidget_3Dp.bbg @@ -33,7 +33,7 @@ COMPLEX_PORT _VecImageLayer 160.000262:115.179274:-900.000000 FIN_COMPLEX_PORT -BOXES:76 +BOXES:85 BOX PackRecalage:ImageSwitcherBox:switch ISEXEC:FALSE @@ -109,8 +109,8 @@ FIN_BOX BOX wx:LayoutSplit:Box12 ISEXEC:FALSE --93.887764:-111.585904:-900.000000 --71.127764:-114.085904:-900.000000 +-93.732506:-110.809616:-900.000000 +-70.972506:-113.309616:-900.000000 FIN_BOX BOX PackRecalage:ImageSwitcherFilter:Box17 @@ -239,8 +239,8 @@ FIN_BOX BOX wx:LayoutLine:Box42 ISEXEC:FALSE --80.172913:-94.750733:-900.000000 --46.852913:-97.250733:-900.000000 +-74.350754:-87.220741:-900.000000 +-41.030754:-89.720741:-900.000000 PORT WinTitle:"Plane XZ (rotation/slice Y)" FIN_BOX @@ -503,8 +503,8 @@ FIN_BOX BOX wx:Slider:Box99 ISEXEC:FALSE --123.474901:-74.501498:-900.000000 --93.674901:-77.001498:-900.000000 +-82.487827:-53.561725:-900.000000 +-52.687827:-56.061725:-900.000000 PORT In:"0" PORT @@ -598,7 +598,83 @@ ISEXEC:FALSE -22.117352:-157.289903:-900.000000 0.527648:-159.789903:-900.000000 FIN_BOX -CONNECTIONS:127 +BOX +wx:LayoutLine:Box116 +ISEXEC:FALSE +-76.532877:-80.237058:-900.000000 +-43.212877:-82.737058:-900.000000 +PORT +Orientation:"H" +FIN_BOX +BOX +std:ConcatStrings:Box120 +ISEXEC:FALSE +-19.249404:-164.916324:-900.000000 +3.510596:-167.416324:-900.000000 +FIN_BOX +BOX +std:GetVectorDoubleElement:Box121 +ISEXEC:FALSE +-22.077888:-171.201844:-900.000000 +1.157112:-173.701844:-900.000000 +PORT +I:"0" +FIN_BOX +BOX +std:GetVectorDoubleElement:Box122 +ISEXEC:FALSE +12.192913:-171.015950:-900.000000 +35.427913:-173.515950:-900.000000 +PORT +I:"1" +FIN_BOX +BOX +std:ConcatStrings:Box123 +ISEXEC:FALSE +-122.007325:-98.426263:-900.000000 +-99.247325:-100.926263:-900.000000 +PORT +In2:" " +FIN_BOX +BOX +creaMaracasVisu:SliderMinMax-flexible:Box124 +ISEXEC:FALSE +-106.780914:-47.752081:-900.000000 +-83.955914:-50.252081:-900.000000 +PORT +showactual:"false" +FIN_BOX +BOX +wx:LayoutLine:Box133 +ISEXEC:FALSE +-123.043494:-82.238461:-900.000000 +-89.723494:-84.738461:-900.000000 +PORT +Orientation:"V" +FIN_BOX +BOX +wx:Slider:Box134 +ISEXEC:FALSE +-126.310102:-73.742981:-900.000000 +-96.510102:-76.242981:-900.000000 +PORT +Label:"true" +PORT +ReactiveOnTrack:"true" +PORT +Title:"Min color table&&2P&&" +FIN_BOX +BOX +wx:Slider:Box135 +ISEXEC:FALSE +-118.061111:-68.118047:-900.000000 +-88.261111:-70.618047:-900.000000 +PORT +ReactiveOnTrack:"true" +PORT +Title:"Max color table&&2P&&" +FIN_BOX +CONNECTIONS:142 CONNECTION checkS:Out:switch:On NumberOfControlPoints:0 @@ -894,9 +970,6 @@ CONNECTION Box99:Out:Box95:Opacity NumberOfControlPoints:0 CONNECTION -Box99:Widget:Box48:Widget3 -NumberOfControlPoints:0 -CONNECTION Box101:Out:Box100:In NumberOfControlPoints:0 CONNECTION @@ -957,27 +1030,75 @@ CONNECTION Box113:Out:Box118:In NumberOfControlPoints:0 CONNECTION -Box118:MinMax:Box106:lstRangeForColorBar +Box57:BoxChange:Box117:In3 NumberOfControlPoints:0 CONNECTION -Box118:MinMax:Box105:lstRangeForColorBar +Box55:Out:Box24:WindowLevel NumberOfControlPoints:0 CONNECTION -Box118:MinMax:Box95:lstRangeForColorBar +Box56:Out:Box24:ColorLevel NumberOfControlPoints:0 CONNECTION -Box57:BoxChange:Box117:In3 +Box55:Out:Box28:WindowLevel NumberOfControlPoints:0 CONNECTION -Box55:Out:Box24:WindowLevel +Box56:Out:Box28:ColorLevel NumberOfControlPoints:0 CONNECTION -Box56:Out:Box24:ColorLevel +Box99:Widget:Box116:Widget4 NumberOfControlPoints:0 CONNECTION -Box55:Out:Box28:WindowLevel +Box118:MinMax:Box120:In1 NumberOfControlPoints:0 CONNECTION -Box56:Out:Box28:ColorLevel +Box120:Out:Box121:In +NumberOfControlPoints:0 +CONNECTION +Box120:Out:Box122:In +NumberOfControlPoints:0 +CONNECTION +Box123:Out:Box95:lstRangeForColorBar +NumberOfControlPoints:0 +CONNECTION +Box123:Out:Box105:lstRangeForColorBar +NumberOfControlPoints:0 +CONNECTION +Box123:Out:Box106:lstRangeForColorBar +NumberOfControlPoints:0 +CONNECTION +Box116:Widget:Box48:Widget4 +NumberOfControlPoints:0 +CONNECTION +Box134:Widget:Box133:Widget1 +NumberOfControlPoints:0 +CONNECTION +Box135:Widget:Box133:Widget2 +NumberOfControlPoints:0 +CONNECTION +Box121:Out:Box134:Min +NumberOfControlPoints:0 +CONNECTION +Box121:Out:Box135:Min +NumberOfControlPoints:0 +CONNECTION +Box122:Out:Box135:Max +NumberOfControlPoints:0 +CONNECTION +Box122:Out:Box134:Max +NumberOfControlPoints:0 +CONNECTION +Box133:Widget:Box116:Widget2 +NumberOfControlPoints:0 +CONNECTION +Box134:Out:Box123:In1 +NumberOfControlPoints:0 +CONNECTION +Box135:Out:Box123:In3 +NumberOfControlPoints:0 +CONNECTION +Box57:BoxChange:Box135:BoxExecute +NumberOfControlPoints:0 +CONNECTION +Box57:BoxChange:Box134:BoxExecute NumberOfControlPoints:0 APP_END diff --git a/PackRecalage/bbs/boxes/CompareImagesSwitcherWidget_3Dp.bbs b/PackRecalage/bbs/boxes/CompareImagesSwitcherWidget_3Dp.bbs index f53cd70..e7114b2 100644 --- a/PackRecalage/bbs/boxes/CompareImagesSwitcherWidget_3Dp.bbs +++ b/PackRecalage/bbs/boxes/CompareImagesSwitcherWidget_3Dp.bbs @@ -224,6 +224,35 @@ new std:MultipleInputs Box117 new vtk:ImageVtkProperties Box118 +new wx:LayoutLine Box116 + set Box116.Orientation "H" + +new std:ConcatStrings Box120 + +new std:GetVectorDoubleElement Box121 + set Box121.I "0" + +new std:GetVectorDoubleElement Box122 + set Box122.I "1" + +new std:ConcatStrings Box123 + set Box123.In2 " " + +new creaMaracasVisu:SliderMinMax-flexible Box124 + set Box124.showactual "false" + +new wx:LayoutLine Box133 + set Box133.Orientation "V" + +new wx:Slider Box134 + set Box134.Label "true" + set Box134.ReactiveOnTrack "true" + set Box134.Title "Min color table:" + +new wx:Slider Box135 + set Box135.ReactiveOnTrack "true" + set Box135.Title "Max color table:" + connect checkS.Out switch.On connect sdrT.Out switch.Time @@ -319,7 +348,6 @@ connect checkS.Out Box98.In1 connect Box98.Out Box96.In2 connect Box24.wxVtkBaseView1 Box95.WxVtkBaseView connect Box99.Out Box95.Opacity -connect Box99.Widget Box48.Widget3 connect Box101.Out Box100.In connect Box99.Out Box105.Opacity connect Box99.Out Box106.Opacity @@ -339,14 +367,30 @@ connect Box117.BoxChange Box95.BoxExecute connect Box117.BoxChange Box105.BoxExecute connect Box117.BoxChange Box106.BoxExecute connect Box113.Out Box118.In -connect Box118.MinMax Box106.lstRangeForColorBar -connect Box118.MinMax Box105.lstRangeForColorBar -connect Box118.MinMax Box95.lstRangeForColorBar connect Box57.BoxChange Box117.In3 connect Box55.Out Box24.WindowLevel connect Box56.Out Box24.ColorLevel connect Box55.Out Box28.WindowLevel connect Box56.Out Box28.ColorLevel +connect Box99.Widget Box116.Widget4 +connect Box118.MinMax Box120.In1 +connect Box120.Out Box121.In +connect Box120.Out Box122.In +connect Box123.Out Box95.lstRangeForColorBar +connect Box123.Out Box105.lstRangeForColorBar +connect Box123.Out Box106.lstRangeForColorBar +connect Box116.Widget Box48.Widget4 +connect Box134.Widget Box133.Widget1 +connect Box135.Widget Box133.Widget2 +connect Box121.Out Box134.Min +connect Box121.Out Box135.Min +connect Box122.Out Box135.Max +connect Box122.Out Box134.Max +connect Box133.Widget Box116.Widget2 +connect Box134.Out Box123.In1 +connect Box135.Out Box123.In3 +connect Box57.BoxChange Box135.BoxExecute +connect Box57.BoxChange Box134.BoxExecute # Complex input ports input ImageVector1 Box22.In " " diff --git a/PackRecalage/src/bbPackRecalageImageConvolution.cxx b/PackRecalage/src/bbPackRecalageImageConvolution.cxx index f062a1c..0b98cf4 100644 --- a/PackRecalage/src/bbPackRecalageImageConvolution.cxx +++ b/PackRecalage/src/bbPackRecalageImageConvolution.cxx @@ -23,7 +23,6 @@ # ------------------------------------------------------------------------ */ - #include "bbPackRecalageImageConvolution.h" #include "bbPackRecalagePackage.h" namespace bbPackRecalage @@ -35,9 +34,10 @@ void ImageConvolution::Process() { if(convolution != NULL && bbGetInputIn() != NULL) { - convolution->setImage(bbGetInputIn()); - convolution->setFactor(bbGetInputFactor()); - convolution->setOn(bbGetInputOn()); + convolution->setImage( bbGetInputIn() ); + convolution->setType( bbGetInputType() ); + convolution->setFactor( bbGetInputFactor() ); + convolution->setOn( bbGetInputOn() ); convolution->Run(); bbSetOutputOut(convolution->getImage()); }// if @@ -45,10 +45,11 @@ void ImageConvolution::Process() void ImageConvolution::bbUserSetDefaultValues() { - bbSetInputIn(NULL); - bbSetOutputOut(NULL); + bbSetInputIn(NULL); + bbSetInputType(0); bbSetInputFactor(5.0); bbSetInputOn(false); + bbSetOutputOut(NULL); } void ImageConvolution::bbUserInitializeProcessing() diff --git a/PackRecalage/src/bbPackRecalageImageConvolution.h b/PackRecalage/src/bbPackRecalageImageConvolution.h index 873805c..45f9693 100644 --- a/PackRecalage/src/bbPackRecalageImageConvolution.h +++ b/PackRecalage/src/bbPackRecalageImageConvolution.h @@ -23,7 +23,6 @@ # ------------------------------------------------------------------------ */ - #ifndef __bbPackRecalageImageConvolution_h_INCLUDED__ #define __bbPackRecalageImageConvolution_h_INCLUDED__ #include "bbPackRecalage_EXPORT.h" @@ -44,6 +43,7 @@ class bbPackRecalage_EXPORT ImageConvolution BBTK_DECLARE_INPUT(In,vtkImageData*); BBTK_DECLARE_INPUT(Factor,double); BBTK_DECLARE_INPUT(On,bool); + BBTK_DECLARE_INPUT(Type,int); BBTK_DECLARE_OUTPUT(Out,vtkImageData*); BBTK_PROCESS(Process); void Process(); @@ -57,13 +57,11 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(ImageConvolution,bbtk::AtomicBlackBox); BBTK_AUTHOR("jn.trillos44@uniandes.edu.co"); BBTK_DESCRIPTION("Processes an image through different convolution matrix (Edge detect)"); BBTK_CATEGORY("filter"); - BBTK_INPUT(ImageConvolution,In,"Image to be filetered",vtkImageData*,""); BBTK_INPUT(ImageConvolution,Factor,"Factor by how the edges will be represented",double,""); BBTK_INPUT(ImageConvolution,On,"(default false) Boolean that represents if the filter is turned on. True = On.",bool,""); - + BBTK_INPUT(ImageConvolution,Type,"(default 0) 0: 2D_kernel3x3 (border Factor=4) 10: 3D_kernel3x3x3 (border Factor=6) 11: 3D_kernel3x3x3 (border Factor=26)",int,""); BBTK_OUTPUT(ImageConvolution,Out,"Filtered Image",vtkImageData*,""); - BBTK_END_DESCRIBE_BLACK_BOX(ImageConvolution); } // EO namespace bbPackRecalage diff --git a/lib/Convolution.cxx b/lib/Convolution.cxx index 4957b05..66fd75a 100644 --- a/lib/Convolution.cxx +++ b/lib/Convolution.cxx @@ -32,6 +32,7 @@ //------------------------------------------------------------ Convolution::Convolution() { + _type = 0; _image = NULL; _convolve = vtkImageConvolve::New(); _cast = vtkImageCast::New(); @@ -74,33 +75,40 @@ void Convolution::setOn(bool on) _on = on; } +void Convolution::setType(int type) +{ + _type = type; +} + void Convolution::Run() { if(_on==true) { -// double kernel[] = { 0.0,1.0,0.0, 1.0,-_factor,1.0, 0.0,1.0,0.0}; -// _convolve->SetKernel3x3(kernel); - -// falta - double kernel[] = { - 0.0,0.0,0.0, 0.0,1,0.0, 0.0,0.0,0.0, - 0.0,1.0,0.0, 1.0,-_factor,1.0, 0.0,1.0,0.0, - 0.0,0.0,0.0, 0.0,1,0.0, 0.0,0.0,0.0 - }; - -//bien -// double kernel[] = { -// 1.0,1.0,1.0, 1.0,1.0,1.0, 1.0,1.0,1.0, -// 1.0,1.0,1.0, 1.0,-_factor,1.0, 1.0,1.0,1.0, -// 1.0,1.0,1.0, 1.0,1.0,1.0, 1.0,1.0,1.0 -// }; -// double kernel[] = { -// -1.0,-1.0,-1.0, -1.0,-1.0,-1.0, -1.0,-1.0,-1.0, -// -1.0,-1.0,-1.0, -1.0,_factor,-1.0, -1.0,-1.0,-1.0, -// -1.0,-1.0,-1.0, -1.0,-1.0,-1.0, -1.0,-1.0,-1.0 -// }; - - _convolve->SetKernel3x3x3(kernel); + if (_type==0) + { + double kernel[] = { 0.0,1.0,0.0, 1.0,-_factor,1.0, 0.0,1.0,0.0}; + _convolve->SetKernel3x3(kernel); + } // if _type==0 + + if (_type==10) + { + double kernel[] = { + 0.0,0.0,0.0, 0.0,1,0.0, 0.0,0.0,0.0, + 0.0,1.0,0.0, 1.0,-_factor,1.0, 0.0,1.0,0.0, + 0.0,0.0,0.0, 0.0,1,0.0, 0.0,0.0,0.0 + }; + _convolve->SetKernel3x3x3(kernel); + } + + if (_type==11) + { + double kernel[] = { + 1.0,1.0,1.0, 1.0,1.0,1.0, 1.0,1.0,1.0, + 1.0,1.0,1.0, 1.0,-_factor,1.0, 1.0,1.0,1.0, + 1.0,1.0,1.0, 1.0,1.0,1.0, 1.0,1.0,1.0 + }; + _convolve->SetKernel3x3x3(kernel); + } _convolve->Update(); //EED 2017-01-01 Migration VTK7 diff --git a/lib/Convolution.h b/lib/Convolution.h index 3758a05..888cf48 100644 --- a/lib/Convolution.h +++ b/lib/Convolution.h @@ -38,31 +38,23 @@ class Convolution public: Convolution(); ~Convolution(); - //Gets the result vtkImageData* getImage(); - void setImage(vtkImageData *image); void setFactor(double factor); - void setOn(bool on); - + void setOn(bool on); + void setType(int type); void Run(); - // --- Atributes --- // - private: - + private: //Original Image vtkImageData *_image; - //Convolution factor double _factor; - //Convolution Filter vtkImageConvolve *_convolve; - //Casting Filter vtkImageCast *_cast; - bool _on; + int _type; }; -