From: trillos Date: Wed, 7 Oct 2009 15:45:51 +0000 (+0000) Subject: New items X-Git-Tag: CREATOOLS.2-0-3~61 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=aa1b23f7a0b103bc3fd8989c0e60b97697adbbc3;hp=bd79966de4ad9bd5e2991c37c281ab8d1e49161f;p=creaRigidRegistration.git New items --- diff --git a/PackRecalage/bbs/appli/ViewerMerge2DInteractiveDemoFabianADC.bbs b/PackRecalage/bbs/appli/ViewerMerge2DInteractiveDemoFabianADC.bbs new file mode 100644 index 0000000..0cd8d77 --- /dev/null +++ b/PackRecalage/bbs/appli/ViewerMerge2DInteractiveDemoFabianADC.bbs @@ -0,0 +1,397 @@ +load wx +load std +load vtk +load wxvtk +load creaMaracasVisu +load PackVisuImages +//load creaImageIO + +load PackRecalage + +//include vtk/boxes/bbLoadHola +//new LoadHola image + +new FileSelector imageSelector1 +new FileSelector imageSelector2 + +new MetaImageReader image + connect imageSelector1.Out image.In + +new MetaImageReader image2 + connect imageSelector2.Out image2.In + + +#new Gimmick image +#new Gimmick image2 + +#Viewer containing image 1 + +new LayoutLine v1Layout +new ViewerNV viewer1 +connect image.Out viewer1.In +set viewer1.nTypeView "0" +connect viewer1.Widget v1Layout.Widget1 + + +#Viewer containing image 2 + +new LayoutLine v2Layout +new ViewerNV viewer2 +connect image2.Out viewer2.In +set viewer2.nTypeView "0" +connect viewer2.Widget v2Layout.Widget1 + +#LayoutSplit were the images will be + +new LayoutSplit initialImages +set initialImages.Proportion "50" +set initialImages.Orientation H +connect v1Layout.Widget initialImages.Widget1 +connect v2Layout.Widget initialImages.Widget2 + +#Layout line that will contain the buttons + +new LayoutLine buttonsLayout + set buttonsLayout.Orientation V + +#Slider were the angle will be entered + +new Slider slider + set slider.Title "Angle" + set slider.In 0 + set slider.Min 0 + set slider.Max 360 + set slider.ReactiveOnTrack "1" + connect slider.Widget buttonsLayout.Widget1 + + + +#Slider were the xScale will be entered + +new Slider sliderX + set sliderX.Title "% Scale in X" + set sliderX.In 100 + set sliderX.Min 10 + set sliderX.Max 500 + set sliderX.ReactiveOnTrack "1" + connect sliderX.Widget buttonsLayout.Widget2 + + + +#Slider were the yScale will be entered + +new Slider sliderY + set sliderY.Title "% Scale in Y" + set sliderY.In 100 + set sliderY.Min 10 + set sliderY.Max 500 + set sliderY.ReactiveOnTrack "1" + connect sliderY.Widget buttonsLayout.Widget3 + + +#Box were the transformation will be made + +new Transform2DBox transform + connect viewer2.Point transform.CenterPoint + connect slider.Out transform.Angle + connect sliderX.Out transform.ScaleX + connect sliderY.Out transform.ScaleY + + + +new ReSlicerBox reslice1 + connect viewer1.Point reslice1.Origin + connect transform.Out reslice1.Transform + connect image2.Out reslice1.In + +new SliceImage slice1 + connect reslice1.Out slice1.In + set slice1.Z "1" + +new Viewer2D viewer2d + connect reslice1.Out viewer2d.In + set viewer2d.Slice "1" + +#new ViewerNV viewer3 + #connect reslice1.Out viewer3.In + #set viewer3.nTypeView "5" + #set viewer3.WinWidth "600" + +# Create the reslicers + +new SliceImage imgslice1 +new SliceImage imgslice2 + connect image.Out imgslice1.In + connect reslice1.Out imgslice2.In + +# Create the visulization box +new CheckBoardBox cbb + connect imgslice1.Out cbb.In1 + connect imgslice2.Out cbb.In2 + +# Create the slider1 +new Slider sdr + set sdr.ReactiveOnTrack 1 + set sdr.Max 50 + set sdr.In 14 + +# Create the slider2 +new Slider sdr2 + set sdr2.ReactiveOnTrack 1 + set sdr2.Max 50 + set sdr2.In 14 + +# Create the ZSlider for the slices + +new Slider sdrZ + set sdrZ.ReactiveOnTrack 1 + set sdrZ.Max 50 + set sdrZ.Title "Z for slice" + +connect sdrZ.Out imgslice1.Z +connect sdrZ.Out imgslice2.Z +connect sdrZ.BoxChange imgslice1.BoxExecute +connect sdrZ.BoxChange imgslice2.BoxExecute + +# Create viewer & layout +new LayoutSplit checkerBoard +new LayoutLine ly +new ViewerNV viewerCH + set viewerCH.nTypeView "0" + set checkerBoard.Proportion 80 + +# Graphical pipeline + connect sdr.Out cbb.Cols + connect sdr2.Out cbb.Rows + connect cbb.Out viewerCH.In + + #connect sdrZ.Widget ly.Widget1 + connect sdr.Widget ly.Widget2 + connect sdr2.Widget ly.Widget3 + + connect viewerCH.Widget checkerBoard.Widget1 + connect ly.Widget checkerBoard.Widget2 + +# Create Surface View + +new SurfaceCreator surf + set surf.Color1 RED + set surf.Color2 BLUE + + connect imgslice1.Out surf.Image1 + connect imgslice2.Out surf.Image2 + +new Slider sdrSurf1 + set sdrSurf1.Min -500 + set sdrSurf1.Max 500 + set sdrSurf1.In 100 + +new Slider sdrSurf2 + set sdrSurf2.Min -500 + set sdrSurf2.Max 500 + set sdrSurf2.In 300 + + connect sdrSurf1.Out surf.Height1 + connect sdrSurf2.Out surf.Height2 + +# Create Surface Layouts + +new LayoutSplit surface +new LayoutLine lySurf +new Viewer3D viewerSurf + set surface.Proportion 80 + connect sdrSurf1.Widget lySurf.Widget1 + connect sdrSurf2.Widget lySurf.Widget2 + connect viewerSurf.Renderer surf.Renderer + #connect lySurf.BoxChange viewerSurf.BoxExecute + + connect surf.Out1 viewerSurf.In1 + connect surf.Out2 viewerSurf.In2 + + connect viewerSurf.Widget surface.Widget1 + connect lySurf.Widget surface.Widget2 + +#Create Substraction View + +new ImageSubstraction imageSub + connect imgslice1.Out imageSub.In1 + connect imgslice2.Out imageSub.In2 + +new Slider sdrSub1 + set sdrSub1.In 51 + set sdrSub1.Max 255 + set sdrSub1.Min 0 + set sdrSub1.Title "Upper Zero Level" + +new Slider sdrSub2 + set sdrSub2.In 49 + set sdrSub2.Max 255 + set sdrSub2.Min 0 + set sdrSub2.Title "Lower Zero Level" + + connect sdrSub1.Out imageSub.In3 + connect sdrSub2.Out imageSub.In4 + +new ColourSelectorButton colorU +new ColourSelectorButton colorM +new ColourSelectorButton colorL + + set colorU.WinTitle "Upper Level Colour" + set colorM.WinTitle "Middle Level Colour" + set colorL.WinTitle "Lower Level Colour" + + set colorU.In "0" + set colorM.In "50,50,50" + set colorL.In "1" + + connect colorU.Out imageSub.InU + connect colorM.Out imageSub.InM + connect colorL.Out imageSub.InL + +#Create substraction layout + +new Viewer2D subView + connect imageSub.Out subView.In + +new LayoutSplit substraction +new LayoutLine lySub + + connect sdrSub1.Widget lySub.Widget1 + connect sdrSub2.Widget lySub.Widget2 + +new LayoutLine lySubColor + + set lySubColor.Orientation H + connect colorU.Widget lySubColor.Widget1 + connect colorM.Widget lySubColor.Widget2 + connect colorL.Widget lySubColor.Widget3 + + connect lySubColor.Widget lySub.Widget3 + + set substraction.Proportion "70" + + connect subView.Widget substraction.Widget1 + connect lySub.Widget substraction.Widget2 +/* +# Create the transparency box +new Transparency tb + connect imgslice1.Out tb.Image1 + connect imgslice2.Out tb.Image2 + +# Create viewer and add actors +new Viewer3D transparency + connect tb.Actor1 transparency.In1 + connect tb.Actor2 transparency.In2 + +*/ +#Multiple inputs for managing the interaction + +new MultipleInputs mult + connect slider.BoxChange mult.In1 + connect sliderX.BoxChange mult.In2 + connect sliderY.BoxChange mult.In3 + connect viewer1.BoxChange mult.In4 + connect viewer2.BoxChange mult.In5 + #connect mult.BoxChange viewer3.BoxExecute + #connect mult.BoxChange viewer2d.BoxExecute + + +# Execution pipeline for checkboard + +new MultipleInputs mult2 + connect ly.BoxChange mult2.In1 + connect mult.BoxChange mult2.In2 + connect imgslice1.BoxChange mult2.In3 + connect imgslice2.BoxChange mult2.In4 + +connect mult2.BoxChange cbb.BoxExecute +connect cbb.BoxChange viewerCH.BoxExecute + +# Execution pipeline for Surface + +new MultipleInputs mult3 + connect mult2.BoxChange mult3.In1 + connect sdrSurf1.BoxChange mult3.In2 + connect sdrSurf2.BoxChange mult3.In3 + + connect mult3.BoxChange surf.BoxExecute + connect surf.BoxChange viewerSurf.BoxExecute + +#Execution pipeline for Substraction + +new MultipleInputs mult4 + connect sdrSub1.BoxChange mult4.In1 + connect sdrSub2.BoxChange mult4.In2 + connect mult2.BoxChange mult4.In3 + +new MultipleInputs mult5 + connect mult4.BoxChange mult5.In1 + connect colorU.BoxChange mult5.In2 + connect colorM.BoxChange mult5.In3 + connect colorL.BoxChange mult5.In4 + + connect mult5.BoxChange imageSub.BoxExecute + connect imageSub.BoxChange substraction.BoxExecute + +#Execution pipeline for Transparency +/* +connect mult2.BoxChange tb.BoxExecute +connect tb.BoxChange transparency.BoxExecute +*/ +# Button for saving + +new CommandButton saveBut + set saveBut.Label "Save Image" + +new FileSelector fileSave + set fileSave.OpenSave "Save" + set fileSave.Wildcard "*.mhd" + +new MetaImageWriter writSave + connect reslice1.Out writSave.In + connect fileSave.Out writSave.Filename + + connect saveBut.BoxChange fileSave.BoxExecute + connect fileSave.BoxChange writSave.BoxExecute + +#Layout were the images and the buttones will be displayed + +new LayoutSplit window1 + set window1.WinWidth "600" + set window1.Proportion "80" + set window1.Orientation V + connect initialImages.Widget window1.Widget1 + connect buttonsLayout.Widget window1.Widget2 + +#new LayoutSplit checkBoard + #set window1.WinWidth "600" + #set window1.Proportion "80" + #set window1.Orientation V + #connect viewer3.Widget checkBoard.Widget1 + #connect checkView.Widget checkBoard.Widget1 + +new LayoutTab tabs + connect checkerBoard.Widget tabs.Widget1 + connect surface.Widget tabs.Widget2 + connect substraction.Widget tabs.Widget3 + //connect transparency.Widget tabs.Widget4 + +new LayoutLine tools + connect sdrZ.Widget tools.Widget1 + connect saveBut.Widget tools.Widget2 + +new LayoutSplit window2 + connect tabs.Widget window2.Widget1 + connect tools.Widget window2.Widget2 + set window2.Proportion "90" + +new LayoutSplit main + set main.WinWidth "1200" + set main.Proportion "50" + set main.Orientation H + connect window1.Widget main.Widget1 + connect window2.Widget main.Widget2 + +#exec image +#exec image2 +exec main \ No newline at end of file diff --git a/PackRecalage/bbs/appli/ViewerMerge2DInteractiveDemoFabianADCV2.bbs b/PackRecalage/bbs/appli/ViewerMerge2DInteractiveDemoFabianADCV2.bbs new file mode 100644 index 0000000..5e529bf --- /dev/null +++ b/PackRecalage/bbs/appli/ViewerMerge2DInteractiveDemoFabianADCV2.bbs @@ -0,0 +1,48 @@ +load wx +load std +load vtk +load wxvtk +load creaMaracasVisu +load PackVisuImages +//load creaImageIO + +load PackRecalage + +//include vtk/boxes/bbLoadHola +//new LoadHola image + +new MetaImageReader image + set image.In "C:\Documents and Settings\trillos\Bureau\Nicolas\Stage\CreaRecalage\PackRecalage\data\ImagesFabienRecalage\adc-j0.mhd" +//new MetaImageReader image2 + //set image.In "C:\Documents and Settings\trillos\Bureau\Nicolas\Stage\CreaRecalage\PackRecalage\data\ImagesFabienRecalage\adc-j1.mhd" + + +#new Gimmick image +#new Gimmick image2 + +#Viewer containing image 1 + +new LayoutLine v1Layout +new ViewerNV viewer1 +connect image.Out viewer1.In +set viewer1.nTypeView "0" +connect viewer1.Widget v1Layout.Widget1 + + +#Viewer containing image 2 + +new LayoutLine v2Layout +new ViewerNV viewer2 +connect image.Out viewer2.In +set viewer2.nTypeView "0" +connect viewer2.Widget v2Layout.Widget1 + +#LayoutSplit were the images will be + +new LayoutSplit initialImages +set initialImages.Proportion "50" +set initialImages.Orientation H +connect v1Layout.Widget initialImages.Widget1 +connect v2Layout.Widget initialImages.Widget2 + +exec initialImages \ No newline at end of file diff --git a/PackRecalage/bbs/appli/ViewerMerge2DInteractiveDemoFabianPeak.bbs b/PackRecalage/bbs/appli/ViewerMerge2DInteractiveDemoFabianPeak.bbs new file mode 100644 index 0000000..3c0587d --- /dev/null +++ b/PackRecalage/bbs/appli/ViewerMerge2DInteractiveDemoFabianPeak.bbs @@ -0,0 +1,391 @@ +load wx +load std +load vtk +load wxvtk +load creaMaracasVisu +load PackVisuImages +//load creaImageIO + +load PackRecalage + +//include vtk/boxes/bbLoadHola +//new LoadHola image + +new MetaImageReader image + set image.In "C:\Documents and Settings\trillos\Bureau\Nicolas\Stage\CreaRecalage\PackRecalage\data\ImagesFabienRecalage\peak-j0.mhd" +new MetaImageReader image2 + set image.In "C:\Documents and Settings\trillos\Bureau\Nicolas\Stage\CreaRecalage\PackRecalage\data\ImagesFabienRecalage\peak-j1.mhd" + + +#new Gimmick image +#new Gimmick image2 + +#Viewer containing image 1 + +new LayoutLine v1Layout +new ViewerNV viewer1 +connect image.Out viewer1.In +set viewer1.nTypeView "0" +connect viewer1.Widget v1Layout.Widget1 + + +#Viewer containing image 2 + +new LayoutLine v2Layout +new ViewerNV viewer2 +connect image2.Out viewer2.In +set viewer2.nTypeView "0" +connect viewer2.Widget v2Layout.Widget1 + +#LayoutSplit were the images will be + +new LayoutSplit initialImages +set initialImages.Proportion "50" +set initialImages.Orientation H +connect v1Layout.Widget initialImages.Widget1 +connect v2Layout.Widget initialImages.Widget2 + +#Layout line that will contain the buttons + +new LayoutLine buttonsLayout + set buttonsLayout.Orientation V + +#Slider were the angle will be entered + +new Slider slider + set slider.Title "Angle" + set slider.In 0 + set slider.Min 0 + set slider.Max 360 + set slider.ReactiveOnTrack "1" + connect slider.Widget buttonsLayout.Widget1 + + + +#Slider were the xScale will be entered + +new Slider sliderX + set sliderX.Title "% Scale in X" + set sliderX.In 100 + set sliderX.Min 10 + set sliderX.Max 500 + set sliderX.ReactiveOnTrack "1" + connect sliderX.Widget buttonsLayout.Widget2 + + + +#Slider were the yScale will be entered + +new Slider sliderY + set sliderY.Title "% Scale in Y" + set sliderY.In 100 + set sliderY.Min 10 + set sliderY.Max 500 + set sliderY.ReactiveOnTrack "1" + connect sliderY.Widget buttonsLayout.Widget3 + + +#Box were the transformation will be made + +new Transform2DBox transform + connect viewer2.Point transform.CenterPoint + connect slider.Out transform.Angle + connect sliderX.Out transform.ScaleX + connect sliderY.Out transform.ScaleY + + + +new ReSlicerBox reslice1 + connect viewer1.Point reslice1.Origin + connect transform.Out reslice1.Transform + connect image2.Out reslice1.In + +new SliceImage slice1 + connect reslice1.Out slice1.In + set slice1.Z "1" + +new Viewer2D viewer2d + connect reslice1.Out viewer2d.In + set viewer2d.Slice "1" + +#new ViewerNV viewer3 + #connect reslice1.Out viewer3.In + #set viewer3.nTypeView "5" + #set viewer3.WinWidth "600" + +# Create the reslicers + +new SliceImage imgslice1 +new SliceImage imgslice2 + connect image.Out imgslice1.In + connect reslice1.Out imgslice2.In + +# Create the visulization box +new CheckBoardBox cbb + connect imgslice1.Out cbb.In1 + connect imgslice2.Out cbb.In2 + +# Create the slider1 +new Slider sdr + set sdr.ReactiveOnTrack 1 + set sdr.Max 50 + set sdr.In 14 + +# Create the slider2 +new Slider sdr2 + set sdr2.ReactiveOnTrack 1 + set sdr2.Max 50 + set sdr2.In 14 + +# Create the ZSlider for the slices + +new Slider sdrZ + set sdrZ.ReactiveOnTrack 1 + set sdrZ.Max 50 + set sdrZ.Title "Z for slice" + +connect sdrZ.Out imgslice1.Z +connect sdrZ.Out imgslice2.Z +connect sdrZ.BoxChange imgslice1.BoxExecute +connect sdrZ.BoxChange imgslice2.BoxExecute + +# Create viewer & layout +new LayoutSplit checkerBoard +new LayoutLine ly +new Viewer2D viewerCH + set checkerBoard.Proportion 80 + +# Graphical pipeline + connect sdr.Out cbb.Cols + connect sdr2.Out cbb.Rows + connect cbb.Out viewerCH.In + + #connect sdrZ.Widget ly.Widget1 + connect sdr.Widget ly.Widget2 + connect sdr2.Widget ly.Widget3 + + connect viewerCH.Widget checkerBoard.Widget1 + connect ly.Widget checkerBoard.Widget2 + +# Create Surface View + +new SurfaceCreator surf + set surf.Color1 RED + set surf.Color2 BLUE + + connect imgslice1.Out surf.Image1 + connect imgslice2.Out surf.Image2 + +new Slider sdrSurf1 + set sdrSurf1.Min -500 + set sdrSurf1.Max 500 + set sdrSurf1.In 100 + +new Slider sdrSurf2 + set sdrSurf2.Min -500 + set sdrSurf2.Max 500 + set sdrSurf2.In 300 + + connect sdrSurf1.Out surf.Height1 + connect sdrSurf2.Out surf.Height2 + +# Create Surface Layouts + +new LayoutSplit surface +new LayoutLine lySurf +new Viewer3D viewerSurf + set surface.Proportion 80 + connect sdrSurf1.Widget lySurf.Widget1 + connect sdrSurf2.Widget lySurf.Widget2 + connect viewerSurf.Renderer surf.Renderer + #connect lySurf.BoxChange viewerSurf.BoxExecute + + connect surf.Out1 viewerSurf.In1 + connect surf.Out2 viewerSurf.In2 + + connect viewerSurf.Widget surface.Widget1 + connect lySurf.Widget surface.Widget2 + +#Create Substraction View + +new ImageSubstraction imageSub + connect imgslice1.Out imageSub.In1 + connect imgslice2.Out imageSub.In2 + +new Slider sdrSub1 + set sdrSub1.In 51 + set sdrSub1.Max 255 + set sdrSub1.Min 0 + set sdrSub1.Title "Upper Zero Level" + +new Slider sdrSub2 + set sdrSub2.In 49 + set sdrSub2.Max 255 + set sdrSub2.Min 0 + set sdrSub2.Title "Lower Zero Level" + + connect sdrSub1.Out imageSub.In3 + connect sdrSub2.Out imageSub.In4 + +new ColourSelectorButton colorU +new ColourSelectorButton colorM +new ColourSelectorButton colorL + + set colorU.WinTitle "Upper Level Colour" + set colorM.WinTitle "Middle Level Colour" + set colorL.WinTitle "Lower Level Colour" + + set colorU.In "0" + set colorM.In "50,50,50" + set colorL.In "1" + + connect colorU.Out imageSub.InU + connect colorM.Out imageSub.InM + connect colorL.Out imageSub.InL + +#Create substraction layout + +new Viewer2D subView + connect imageSub.Out subView.In + +new LayoutSplit substraction +new LayoutLine lySub + + connect sdrSub1.Widget lySub.Widget1 + connect sdrSub2.Widget lySub.Widget2 + +new LayoutLine lySubColor + + set lySubColor.Orientation H + connect colorU.Widget lySubColor.Widget1 + connect colorM.Widget lySubColor.Widget2 + connect colorL.Widget lySubColor.Widget3 + + connect lySubColor.Widget lySub.Widget3 + + set substraction.Proportion "70" + + connect subView.Widget substraction.Widget1 + connect lySub.Widget substraction.Widget2 + +# Create the transparency box +new Transparency tb + connect imgslice1.Out tb.Image1 + connect imgslice2.Out tb.Image2 + +# Create viewer and add actors +new Viewer3D transparency + connect tb.Actor1 transparency.In1 + connect tb.Actor2 transparency.In2 + +#Multiple inputs for managing the interaction + +new MultipleInputs mult + connect slider.BoxChange mult.In1 + connect sliderX.BoxChange mult.In2 + connect sliderY.BoxChange mult.In3 + connect viewer1.BoxChange mult.In4 + connect viewer2.BoxChange mult.In5 + #connect mult.BoxChange viewer3.BoxExecute + #connect mult.BoxChange viewer2d.BoxExecute + + +# Execution pipeline for checkboard + +new MultipleInputs mult2 + connect ly.BoxChange mult2.In1 + connect mult.BoxChange mult2.In2 + connect imgslice1.BoxChange mult2.In3 + connect imgslice2.BoxChange mult2.In4 + +connect mult2.BoxChange cbb.BoxExecute +connect cbb.BoxChange viewerCH.BoxExecute + +# Execution pipeline for Surface + +new MultipleInputs mult3 + connect mult2.BoxChange mult3.In1 + connect sdrSurf1.BoxChange mult3.In2 + connect sdrSurf2.BoxChange mult3.In3 + + connect mult3.BoxChange surf.BoxExecute + connect surf.BoxChange viewerSurf.BoxExecute + +#Execution pipeline for Substraction + +new MultipleInputs mult4 + connect sdrSub1.BoxChange mult4.In1 + connect sdrSub2.BoxChange mult4.In2 + connect mult2.BoxChange mult4.In3 + +new MultipleInputs mult5 + connect mult4.BoxChange mult5.In1 + connect colorU.BoxChange mult5.In2 + connect colorM.BoxChange mult5.In3 + connect colorL.BoxChange mult5.In4 + + connect mult5.BoxChange imageSub.BoxExecute + connect imageSub.BoxChange substraction.BoxExecute + +#Execution pipeline for Transparency + +connect mult2.BoxChange tb.BoxExecute +connect tb.BoxChange transparency.BoxExecute + +# Button for saving + +new CommandButton saveBut + set saveBut.Label "Save Image" + +new FileSelector fileSave + set fileSave.OpenSave "Save" + set fileSave.Wildcard "*.mhd" + +new MetaImageWriter writSave + connect reslice1.Out writSave.In + connect fileSave.Out writSave.Filename + + connect saveBut.BoxChange fileSave.BoxExecute + connect fileSave.BoxChange writSave.BoxExecute + +#Layout were the images and the buttones will be displayed + +new LayoutSplit window1 + set window1.WinWidth "600" + set window1.Proportion "80" + set window1.Orientation V + connect initialImages.Widget window1.Widget1 + connect buttonsLayout.Widget window1.Widget2 + +#new LayoutSplit checkBoard + #set window1.WinWidth "600" + #set window1.Proportion "80" + #set window1.Orientation V + #connect viewer3.Widget checkBoard.Widget1 + #connect checkView.Widget checkBoard.Widget1 + +new LayoutTab tabs + connect checkerBoard.Widget tabs.Widget1 + connect surface.Widget tabs.Widget2 + connect substraction.Widget tabs.Widget3 + connect transparency.Widget tabs.Widget4 + +new LayoutLine tools + connect sdrZ.Widget tools.Widget1 + connect saveBut.Widget tools.Widget2 + +new LayoutSplit window2 + connect tabs.Widget window2.Widget1 + connect tools.Widget window2.Widget2 + set window2.Proportion "90" + +new LayoutSplit main + set main.WinWidth "1200" + set main.Proportion "50" + set main.Orientation H + connect window1.Widget main.Widget1 + connect window2.Widget main.Widget2 + +#exec image +#exec image2 +exec main \ No newline at end of file diff --git a/PackRecalage/bbs/appli/ViewerMerge2DInteractiveDemoFabianT2.bbs b/PackRecalage/bbs/appli/ViewerMerge2DInteractiveDemoFabianT2.bbs new file mode 100644 index 0000000..4e3664e --- /dev/null +++ b/PackRecalage/bbs/appli/ViewerMerge2DInteractiveDemoFabianT2.bbs @@ -0,0 +1,393 @@ +load wx +load std +load vtk +load wxvtk +load creaMaracasVisu +load PackVisuImages +//load creaImageIO + +load PackRecalage + +//include vtk/boxes/bbLoadHola +//new LoadHola image + +new MetaImageReader image + set image.In "C:\Documents and Settings\trillos\Bureau\Nicolas\Stage\CreaRecalage\PackRecalage\data\ImagesFabienRecalage\t2-j0.mhd" +new MetaImageReader image2 + set image2.In "C:\Documents and Settings\trillos\Bureau\Nicolas\Stage\CreaRecalage\PackRecalage\data\ImagesFabienRecalage\t2-j1.mhd" + + +#new Gimmick image +#new Gimmick image2 + +#Viewer containing image 1 + +new LayoutLine v1Layout +new ViewerNV viewer1 +connect image.Out viewer1.In +set viewer1.nTypeView "0" +connect viewer1.Widget v1Layout.Widget1 + + +#Viewer containing image 2 + +new LayoutLine v2Layout +new ViewerNV viewer2 +connect image2.Out viewer2.In +set viewer2.nTypeView "0" +connect viewer2.Widget v2Layout.Widget1 + +#LayoutSplit were the images will be + +new LayoutSplit initialImages +set initialImages.Proportion "50" +set initialImages.Orientation H +connect v1Layout.Widget initialImages.Widget1 +connect v2Layout.Widget initialImages.Widget2 + +#Layout line that will contain the buttons + +new LayoutLine buttonsLayout + set buttonsLayout.Orientation V + +#Slider were the angle will be entered + +new Slider slider + set slider.Title "Angle" + set slider.In 0 + set slider.Min 0 + set slider.Max 360 + set slider.ReactiveOnTrack "1" + connect slider.Widget buttonsLayout.Widget1 + + + +#Slider were the xScale will be entered + +new Slider sliderX + set sliderX.Title "% Scale in X" + set sliderX.In 100 + set sliderX.Min 10 + set sliderX.Max 500 + set sliderX.ReactiveOnTrack "1" + connect sliderX.Widget buttonsLayout.Widget2 + + + +#Slider were the yScale will be entered + +new Slider sliderY + set sliderY.Title "% Scale in Y" + set sliderY.In 100 + set sliderY.Min 10 + set sliderY.Max 500 + set sliderY.ReactiveOnTrack "1" + connect sliderY.Widget buttonsLayout.Widget3 + + +#Box were the transformation will be made + +new Transform2DBox transform + connect viewer2.Point transform.CenterPoint + connect slider.Out transform.Angle + connect sliderX.Out transform.ScaleX + connect sliderY.Out transform.ScaleY + + + +new ReSlicerBox reslice1 + connect viewer1.Point reslice1.Origin + connect transform.Out reslice1.Transform + connect image2.Out reslice1.In + +new SliceImage slice1 + connect reslice1.Out slice1.In + set slice1.Z "1" + +new Viewer2D viewer2d + connect reslice1.Out viewer2d.In + set viewer2d.Slice "1" + +#new ViewerNV viewer3 + #connect reslice1.Out viewer3.In + #set viewer3.nTypeView "5" + #set viewer3.WinWidth "600" + +# Create the reslicers + +new SliceImage imgslice1 +new SliceImage imgslice2 + connect image.Out imgslice1.In + connect reslice1.Out imgslice2.In + +# Create the visulization box +new CheckBoardBox cbb + connect imgslice1.Out cbb.In1 + connect imgslice2.Out cbb.In2 + +# Create the slider1 +new Slider sdr + set sdr.ReactiveOnTrack 1 + set sdr.Max 50 + set sdr.In 14 + +# Create the slider2 +new Slider sdr2 + set sdr2.ReactiveOnTrack 1 + set sdr2.Max 50 + set sdr2.In 14 + +# Create the ZSlider for the slices + +new Slider sdrZ + set sdrZ.ReactiveOnTrack 1 + set sdrZ.Max 50 + set sdrZ.Title "Z for slice" + +connect sdrZ.Out imgslice1.Z +connect sdrZ.Out imgslice2.Z +connect sdrZ.BoxChange imgslice1.BoxExecute +connect sdrZ.BoxChange imgslice2.BoxExecute + +# Create viewer & layout +new LayoutSplit checkerBoard +new LayoutLine ly +new ViewerNV viewerCH + set viewerCH.nTypeView "0" + set checkerBoard.Proportion 80 + +# Graphical pipeline + connect sdr.Out cbb.Cols + connect sdr2.Out cbb.Rows + connect cbb.Out viewerCH.In + + #connect sdrZ.Widget ly.Widget1 + connect sdr.Widget ly.Widget2 + connect sdr2.Widget ly.Widget3 + + connect viewerCH.Widget checkerBoard.Widget1 + connect ly.Widget checkerBoard.Widget2 + +# Create Surface View + +new SurfaceCreator surf + set surf.Color1 RED + set surf.Color2 BLUE + + connect imgslice1.Out surf.Image1 + connect imgslice2.Out surf.Image2 + +new Slider sdrSurf1 + set sdrSurf1.Min -500 + set sdrSurf1.Max 500 + set sdrSurf1.In 100 + +new Slider sdrSurf2 + set sdrSurf2.Min -500 + set sdrSurf2.Max 500 + set sdrSurf2.In 300 + + connect sdrSurf1.Out surf.Height1 + connect sdrSurf2.Out surf.Height2 + +# Create Surface Layouts + +new LayoutSplit surface +new LayoutLine lySurf +new Viewer3D viewerSurf + set surface.Proportion 80 + connect sdrSurf1.Widget lySurf.Widget1 + connect sdrSurf2.Widget lySurf.Widget2 + connect viewerSurf.Renderer surf.Renderer + #connect lySurf.BoxChange viewerSurf.BoxExecute + + connect surf.Out1 viewerSurf.In1 + connect surf.Out2 viewerSurf.In2 + + connect viewerSurf.Widget surface.Widget1 + connect lySurf.Widget surface.Widget2 + +#Create Substraction View + +new ImageSubstraction imageSub + connect imgslice1.Out imageSub.In1 + connect imgslice2.Out imageSub.In2 + +new Slider sdrSub1 + set sdrSub1.In 51 + set sdrSub1.Max 255 + set sdrSub1.Min 0 + set sdrSub1.Title "Upper Zero Level" + +new Slider sdrSub2 + set sdrSub2.In 49 + set sdrSub2.Max 255 + set sdrSub2.Min 0 + set sdrSub2.Title "Lower Zero Level" + + connect sdrSub1.Out imageSub.In3 + connect sdrSub2.Out imageSub.In4 + +new ColourSelectorButton colorU +new ColourSelectorButton colorM +new ColourSelectorButton colorL + + set colorU.WinTitle "Upper Level Colour" + set colorM.WinTitle "Middle Level Colour" + set colorL.WinTitle "Lower Level Colour" + + set colorU.In "0" + set colorM.In "50,50,50" + set colorL.In "1" + + connect colorU.Out imageSub.InU + connect colorM.Out imageSub.InM + connect colorL.Out imageSub.InL + +#Create substraction layout + +new Viewer2D subView + connect imageSub.Out subView.In + +new LayoutSplit substraction +new LayoutLine lySub + + connect sdrSub1.Widget lySub.Widget1 + connect sdrSub2.Widget lySub.Widget2 + +new LayoutLine lySubColor + + set lySubColor.Orientation H + connect colorU.Widget lySubColor.Widget1 + connect colorM.Widget lySubColor.Widget2 + connect colorL.Widget lySubColor.Widget3 + + connect lySubColor.Widget lySub.Widget3 + + set substraction.Proportion "70" + + connect subView.Widget substraction.Widget1 + connect lySub.Widget substraction.Widget2 +/* +# Create the transparency box +new Transparency tb + connect imgslice1.Out tb.Image1 + connect imgslice2.Out tb.Image2 + +# Create viewer and add actors +new Viewer3D transparency + connect tb.Actor1 transparency.In1 + connect tb.Actor2 transparency.In2 + +*/ +#Multiple inputs for managing the interaction + +new MultipleInputs mult + connect slider.BoxChange mult.In1 + connect sliderX.BoxChange mult.In2 + connect sliderY.BoxChange mult.In3 + connect viewer1.BoxChange mult.In4 + connect viewer2.BoxChange mult.In5 + #connect mult.BoxChange viewer3.BoxExecute + #connect mult.BoxChange viewer2d.BoxExecute + + +# Execution pipeline for checkboard + +new MultipleInputs mult2 + connect ly.BoxChange mult2.In1 + connect mult.BoxChange mult2.In2 + connect imgslice1.BoxChange mult2.In3 + connect imgslice2.BoxChange mult2.In4 + +connect mult2.BoxChange cbb.BoxExecute +connect cbb.BoxChange viewerCH.BoxExecute + +# Execution pipeline for Surface + +new MultipleInputs mult3 + connect mult2.BoxChange mult3.In1 + connect sdrSurf1.BoxChange mult3.In2 + connect sdrSurf2.BoxChange mult3.In3 + + connect mult3.BoxChange surf.BoxExecute + connect surf.BoxChange viewerSurf.BoxExecute + +#Execution pipeline for Substraction + +new MultipleInputs mult4 + connect sdrSub1.BoxChange mult4.In1 + connect sdrSub2.BoxChange mult4.In2 + connect mult2.BoxChange mult4.In3 + +new MultipleInputs mult5 + connect mult4.BoxChange mult5.In1 + connect colorU.BoxChange mult5.In2 + connect colorM.BoxChange mult5.In3 + connect colorL.BoxChange mult5.In4 + + connect mult5.BoxChange imageSub.BoxExecute + connect imageSub.BoxChange substraction.BoxExecute + +#Execution pipeline for Transparency +/* +connect mult2.BoxChange tb.BoxExecute +connect tb.BoxChange transparency.BoxExecute +*/ +# Button for saving + +new CommandButton saveBut + set saveBut.Label "Save Image" + +new FileSelector fileSave + set fileSave.OpenSave "Save" + set fileSave.Wildcard "*.mhd" + +new MetaImageWriter writSave + connect reslice1.Out writSave.In + connect fileSave.Out writSave.Filename + + connect saveBut.BoxChange fileSave.BoxExecute + connect fileSave.BoxChange writSave.BoxExecute + +#Layout were the images and the buttones will be displayed + +new LayoutSplit window1 + set window1.WinWidth "600" + set window1.Proportion "80" + set window1.Orientation V + connect initialImages.Widget window1.Widget1 + connect buttonsLayout.Widget window1.Widget2 + +#new LayoutSplit checkBoard + #set window1.WinWidth "600" + #set window1.Proportion "80" + #set window1.Orientation V + #connect viewer3.Widget checkBoard.Widget1 + #connect checkView.Widget checkBoard.Widget1 + +new LayoutTab tabs + connect checkerBoard.Widget tabs.Widget1 + connect surface.Widget tabs.Widget2 + connect substraction.Widget tabs.Widget3 + //connect transparency.Widget tabs.Widget4 + +new LayoutLine tools + connect sdrZ.Widget tools.Widget1 + connect saveBut.Widget tools.Widget2 + +new LayoutSplit window2 + connect tabs.Widget window2.Widget1 + connect tools.Widget window2.Widget2 + set window2.Proportion "90" + +new LayoutSplit main + set main.WinWidth "1200" + set main.Proportion "50" + set main.Orientation H + connect window1.Widget main.Widget1 + connect window2.Widget main.Widget2 + +#exec image +#exec image2 +exec main \ No newline at end of file diff --git a/PackRecalage/data/ImagesFabienRecalage/README.txt b/PackRecalage/data/ImagesFabienRecalage/README.txt new file mode 100644 index 0000000..bc00655 --- /dev/null +++ b/PackRecalage/data/ImagesFabienRecalage/README.txt @@ -0,0 +1,18 @@ +Probleme 1 +========== +Recalage d'images faites un premier jour (J0) puis un deuxieme (J1) +avec les memes sequences IRM. + +Carto : +- ADC-J1 a recaler sur ADC-J0 (128*128*7coupes, 64bits) +- Peak-J1 a recaler sur Peak-J0 (128*128*8coupes, 64bits) +Images natives: +- T2-J1 a recaler sur T2-J0 (256*256*7, 16bits) + +La transformation est la meme pour les 3 couples (fichiers joints). + +Probleme 2 +========== +Recalage des images natives d'une meme serie temporelle +(probleme technique de mouvement du lit dans l'IRM) +Images natives (128*128*8coupes*100 time points, 16bits) = 2dseq-perfusion diff --git a/PackRecalage/data/ImagesFabienRecalage/adc-j0 b/PackRecalage/data/ImagesFabienRecalage/adc-j0 new file mode 100644 index 0000000..3e7cb46 Binary files /dev/null and b/PackRecalage/data/ImagesFabienRecalage/adc-j0 differ diff --git a/PackRecalage/data/ImagesFabienRecalage/adc-j0.mhd b/PackRecalage/data/ImagesFabienRecalage/adc-j0.mhd new file mode 100644 index 0000000..375469b --- /dev/null +++ b/PackRecalage/data/ImagesFabienRecalage/adc-j0.mhd @@ -0,0 +1,19 @@ +ObjectType = Image +NDims = 3 +DimSize = 128 128 7 +ElementType = MET_DOUBLE +HeaderSize = 0 + +ElementSpacing = 1.0 1.0 1.0 +Position = 0 0 0 +TransformMatrix = 1 0 0 0 1 0 0 0 1 +Offset = 0 0 0 +CenterOfRotation = 0 0 0 +AnatomicalOrientation = ??? + +BinaryData = True +BinaryDataByteOrderMSB = False +CompressedData = False +ElementNumberOfChannels = 1 + +ElementDataFile = adc-j0 diff --git a/PackRecalage/data/ImagesFabienRecalage/adc-j1 b/PackRecalage/data/ImagesFabienRecalage/adc-j1 new file mode 100644 index 0000000..fab9bc0 Binary files /dev/null and b/PackRecalage/data/ImagesFabienRecalage/adc-j1 differ diff --git a/PackRecalage/data/ImagesFabienRecalage/adc-j1.mhd b/PackRecalage/data/ImagesFabienRecalage/adc-j1.mhd new file mode 100644 index 0000000..e73940b --- /dev/null +++ b/PackRecalage/data/ImagesFabienRecalage/adc-j1.mhd @@ -0,0 +1,19 @@ +ObjectType = Image +NDims = 3 +DimSize = 128 128 7 +ElementType = MET_DOUBLE +HeaderSize = 0 + +ElementSpacing = 1.0 1.0 1.0 +Position = 0 0 0 +TransformMatrix = 1 0 0 0 1 0 0 0 1 +Offset = 0 0 0 +CenterOfRotation = 0 0 0 +AnatomicalOrientation = ??? + +BinaryData = True +BinaryDataByteOrderMSB = False +CompressedData = False +ElementNumberOfChannels = 1 + +ElementDataFile = adc-j1 diff --git a/PackRecalage/data/ImagesFabienRecalage/peak-j0 b/PackRecalage/data/ImagesFabienRecalage/peak-j0 new file mode 100644 index 0000000..c3531ae Binary files /dev/null and b/PackRecalage/data/ImagesFabienRecalage/peak-j0 differ diff --git a/PackRecalage/data/ImagesFabienRecalage/peak-j0.mhd b/PackRecalage/data/ImagesFabienRecalage/peak-j0.mhd new file mode 100644 index 0000000..a38eea4 --- /dev/null +++ b/PackRecalage/data/ImagesFabienRecalage/peak-j0.mhd @@ -0,0 +1,19 @@ +ObjectType = Image +NDims = 3 +DimSize = 128 128 8 +ElementType = MET_DOUBLE +HeaderSize = 0 + +ElementSpacing = 1.0 1.0 1.0 +Position = 0 0 0 +TransformMatrix = 1 0 0 0 1 0 0 0 1 +Offset = 0 0 0 +CenterOfRotation = 0 0 0 +AnatomicalOrientation = ??? + +BinaryData = True +BinaryDataByteOrderMSB = False +CompressedData = False +ElementNumberOfChannels = 1 + +ElementDataFile = peak-j0 diff --git a/PackRecalage/data/ImagesFabienRecalage/peak-j1 b/PackRecalage/data/ImagesFabienRecalage/peak-j1 new file mode 100644 index 0000000..403abea Binary files /dev/null and b/PackRecalage/data/ImagesFabienRecalage/peak-j1 differ diff --git a/PackRecalage/data/ImagesFabienRecalage/peak-j1.mhd b/PackRecalage/data/ImagesFabienRecalage/peak-j1.mhd new file mode 100644 index 0000000..f1512ac --- /dev/null +++ b/PackRecalage/data/ImagesFabienRecalage/peak-j1.mhd @@ -0,0 +1,19 @@ +ObjectType = Image +NDims = 3 +DimSize = 128 128 8 +ElementType = MET_DOUBLE +HeaderSize = 0 + +ElementSpacing = 1.0 1.0 1.0 +Position = 0 0 0 +TransformMatrix = 1 0 0 0 1 0 0 0 1 +Offset = 0 0 0 +CenterOfRotation = 0 0 0 +AnatomicalOrientation = ??? + +BinaryData = True +BinaryDataByteOrderMSB = False +CompressedData = False +ElementNumberOfChannels = 1 + +ElementDataFile = peak-j1 diff --git a/PackRecalage/data/ImagesFabienRecalage/t2-j0 b/PackRecalage/data/ImagesFabienRecalage/t2-j0 new file mode 100644 index 0000000..deae155 Binary files /dev/null and b/PackRecalage/data/ImagesFabienRecalage/t2-j0 differ diff --git a/PackRecalage/data/ImagesFabienRecalage/t2-j0.mhd b/PackRecalage/data/ImagesFabienRecalage/t2-j0.mhd new file mode 100644 index 0000000..dd0213a --- /dev/null +++ b/PackRecalage/data/ImagesFabienRecalage/t2-j0.mhd @@ -0,0 +1,19 @@ +ObjectType = Image +NDims = 3 +DimSize = 256 257 7 +ElementType = MET_USHORT +HeaderSize = 0 + +ElementSpacing = 1.0 1.0 1.0 +Position = 0 0 0 +TransformMatrix = 1 0 0 0 1 0 0 0 1 +Offset = 0 0 0 +CenterOfRotation = 0 0 0 +AnatomicalOrientation = ??? + +BinaryData = True +BinaryDataByteOrderMSB = False +CompressedData = False +ElementNumberOfChannels = 1 + +ElementDataFile = t2-j0 diff --git a/PackRecalage/data/ImagesFabienRecalage/t2-j1 b/PackRecalage/data/ImagesFabienRecalage/t2-j1 new file mode 100644 index 0000000..780dd0e Binary files /dev/null and b/PackRecalage/data/ImagesFabienRecalage/t2-j1 differ diff --git a/PackRecalage/data/ImagesFabienRecalage/t2-j1.mhd b/PackRecalage/data/ImagesFabienRecalage/t2-j1.mhd new file mode 100644 index 0000000..5262f6d --- /dev/null +++ b/PackRecalage/data/ImagesFabienRecalage/t2-j1.mhd @@ -0,0 +1,19 @@ +ObjectType = Image +NDims = 3 +DimSize = 256 257 7 +ElementType = MET_USHORT +HeaderSize = 0 + +ElementSpacing = 1.0 1.0 1.0 +Position = 0 0 0 +TransformMatrix = 1 0 0 0 1 0 0 0 1 +Offset = 0 0 0 +CenterOfRotation = 0 0 0 +AnatomicalOrientation = ??? + +BinaryData = True +BinaryDataByteOrderMSB = False +CompressedData = False +ElementNumberOfChannels = 1 + +ElementDataFile = t2-j1 diff --git a/PackRecalage/src/bbPackRecalageImageSubstraction.cxx b/PackRecalage/src/bbPackRecalageImageSubstraction.cxx new file mode 100644 index 0000000..23ef926 --- /dev/null +++ b/PackRecalage/src/bbPackRecalageImageSubstraction.cxx @@ -0,0 +1,249 @@ +#include "bbPackRecalageImageSubstraction.h" +#include "bbPackRecalagePackage.h" +namespace bbPackRecalage +{ + + MyImageSubstraction::MyImageSubstraction(vtkImageData* imageData1,vtkImageData* imageData2, int uZLevel,int lZLevel, std::vector uColor, std::vector lColor, std::vector mColor) +{ + imageResult= vtkImageData::New(); + sizeImage=0; + uZeroLevel=uZLevel; + lZeroLevel=lZLevel; + if(uColor.size() != NULL) + { + upperColor[0] = uColor[0]; + upperColor[1] = uColor[1]; + upperColor[2] = uColor[2]; + } + else + { + upperColor[0] = 255; + upperColor[1] = 255; + upperColor[2] = 255; + } + if(mColor.size() != NULL) + { + mediumColor[0] = mColor[0]; + mediumColor[1] = mColor[1]; + mediumColor[2] = mColor[2]; + } + else + { + mediumColor[0] = 125; + mediumColor[1] = 125; + mediumColor[2] = 125; + } + if(lColor.size() != NULL) + { + lowerColor[0] = lColor[0]; + lowerColor[1] = lColor[1]; + lowerColor[2] = lColor[2]; + } + else + { + lowerColor[0] = 0; + lowerColor[1] = 0; + lowerColor[2] = 0; + } + + //Original image type this case is an unsigned char (3) + int t=imageData1->GetScalarType(); + //substracting the image + substractImage(imageData1, imageData2); +} + +MyImageSubstraction::~MyImageSubstraction() +{ + if(imageResult!=NULL)imageResult->Delete(); +} + +//---------------------------------------------------------------------------- +// Methods +//---------------------------------------------------------------------------- + + +/* +Calculate the new image and save it in the attribute imageResult +it is used if the user had given the imageData +*/ +void MyImageSubstraction::substractImage(vtkImageData* imageData1, vtkImageData* imageData2) +{ + //dimensions of the image (extent) + int ext[6]; + //setting the dimensionality (1d or 2d or 3d ) + int newDim[3]; + //image spacing + double spc[3]; + + //getting the information from the original image + imageData1->GetSpacing(spc); + imageData1->GetExtent(ext); + + //this a 2d image + newDim[0]=ext[1]-ext[0]+1; + newDim[1]=ext[3]-ext[2]+1; + newDim[2]=1;// in general it is ext[5]-ext[4]+1 + + + //initializing the image that represents the substracted image + initialize(newDim,spc); + //Time to substract + substract(imageData1, imageData2); +} + +/* + getting ready the imageResult +*/ +void MyImageSubstraction::initialize(int dimensions[], double spacing[]) +{ + //setting image data of the imageResult + imageResult->SetScalarTypeToUnsignedChar(); + imageResult->SetSpacing(spacing); + imageResult->SetDimensions(dimensions); + imageResult->AllocateScalars(); + imageResult->Update(); +} + +/* + Setting the values for the +*/ +void MyImageSubstraction::substract(vtkImageData* imageData1, vtkImageData* imageData2) +{ + /* + images pointers + */ + //the new image type is unsigned short (5) + int t=imageData1->GetScalarType(); + + // pointers to get into the image + unsigned char* dataImagePointer1=NULL; + unsigned char* dataImagePointer2=NULL; + unsigned char* dataImageResultPointer=NULL; + // we start where the image starts + dataImagePointer1=(unsigned char*)imageData1->GetScalarPointer(0,0,0); + dataImagePointer2=(unsigned char*)imageData2->GetScalarPointer(0,0,0); + dataImageResultPointer=(unsigned char*)imageResult->GetScalarPointer(0,0,0); + + /* + Image Size + */ + int ext[6]; + imageData1->GetExtent(ext); + int sx,sy,sz; + sx=ext[1]-ext[0]+1; + sy=ext[3]-ext[2]+1; + sz=ext[5]-ext[4]+1; + + sizeImage=sx*sy*sz; + + //----------------- + //A3 + //----------------- + //walking in the image + int i=0,j=0,k=0,counter=0,nU=0,nL=0,nZ=0; + double sum1=0,sum2=0; + for(i=0;iGetScalarComponentAsFloat(i,j,k,0); + + // we get the pointer to the position (i,j,k)y that way we can get the + //grey level and we can change it + dataImagePointer1=(unsigned char*)imageData1->GetScalarPointer(i,j,k); + dataImagePointer2=(unsigned char*)imageData2->GetScalarPointer(i,j,k); + dataImageResultPointer=(unsigned char*)imageResult->GetScalarPointer(i,j,k); + + sum1=(int)(dataImagePointer1[0]) + (int)(dataImagePointer1[1]) + (int)(dataImagePointer1[2]); + sum1=sum1/3; + sum2=(int)(dataImagePointer2[0]) + (int)(dataImagePointer2[1]) + (int)(dataImagePointer2[2]); + sum2=sum2/3; + if((sum1 - sum2) < lZeroLevel) + { + dataImageResultPointer[0] =(unsigned char) lowerColor[0]; + dataImageResultPointer[1] =(unsigned char) lowerColor[1]; + dataImageResultPointer[2] =(unsigned char) lowerColor[2]; + nL++; + } + else if((sum1 - sum2) > uZeroLevel) + { + dataImageResultPointer[0] =(unsigned char) upperColor[0]; + dataImageResultPointer[1] =(unsigned char) upperColor[1]; + dataImageResultPointer[2] =(unsigned char) upperColor[2]; + nU++; + } + else + { + dataImageResultPointer[0] =(unsigned char) mediumColor[0]; + dataImageResultPointer[1] =(unsigned char) mediumColor[1]; + dataImageResultPointer[2] =(unsigned char) mediumColor[2]; + nZ++; + } + counter++; + } + } + } +} +/* +Returns the filtered image +*/ +vtkImageData* MyImageSubstraction::getSubstractedImage() +{ + return imageResult; +} + +/* + Get Image Size +*/ +int MyImageSubstraction::getImageSize() +{ + return sizeImage; +} + +BBTK_ADD_BLACK_BOX_TO_PACKAGE(PackRecalage,ImageSubstraction) +BBTK_BLACK_BOX_IMPLEMENTATION(ImageSubstraction,bbtk::AtomicBlackBox); +void ImageSubstraction::Process() +{ + MyImageSubstraction* subImage = new MyImageSubstraction(bbGetInputIn1(),bbGetInputIn2(),bbGetInputIn3(),bbGetInputIn4(),bbGetInputInU(),bbGetInputInL(),bbGetInputInM()); + + bbSetOutputOut(subImage->getSubstractedImage()); +} +void ImageSubstraction::bbUserSetDefaultValues() +{ + bbSetInputIn1(NULL); + bbSetInputIn2(NULL); + bbSetInputIn3(0); + bbSetInputIn4(0); + std::vector vector; + bbSetInputInU(vector); + bbSetInputInM(vector); + bbSetInputInL(vector); + +} +void ImageSubstraction::bbUserInitializeProcessing() +{ + +// THE INITIALIZATION METHOD BODY : +// Here does nothing +// but this is where you should allocate the internal/output pointers +// if any + + +} +void ImageSubstraction::bbUserFinalizeProcessing() +{ + +// THE FINALIZATION METHOD BODY : +// Here does nothing +// but this is where you should desallocate the internal/output pointers +// if any + +} +} +// EO namespace bbCreaRecalage + + diff --git a/PackRecalage/src/bbPackRecalageImageSubstraction.h b/PackRecalage/src/bbPackRecalageImageSubstraction.h new file mode 100644 index 0000000..f2a18e9 --- /dev/null +++ b/PackRecalage/src/bbPackRecalageImageSubstraction.h @@ -0,0 +1,126 @@ +#ifndef __bbPackRecalageImageSubstraction_h_INCLUDED__ +#define __bbPackRecalageImageSubstraction_h_INCLUDED__ +#include "bbPackRecalage_EXPORT.h" +#include "bbtkAtomicBlackBox.h" +#include "iostream" +#include "vtkImageData.h" + +#include +#include + + +namespace bbPackRecalage +{ + + class MyImageSubstraction +{ + + //---------------------------------------------------------------------------------------- + // Methods definition + //---------------------------------------------------------------------------------------- + public: + //-------------------------- + //Constructor & Destructor + //-------------------------- + MyImageSubstraction(vtkImageData* imageData1, vtkImageData* imageData2, int uZLevel,int lZLevel, std::vector uColor, std::vector lColor, std::vector mColor); + ~MyImageSubstraction(); + //-------------------------- + //Methods + //-------------------------- + /* + getting ready the points + */ + void initialize(int dimensions[],double spacing[]); + /* + Calculate the new image and save it in the attribute imageResult + it is used if the user had given the imageData + */ + void substractImage(vtkImageData* imageData1, vtkImageData* imageData2); + + /* + Returns the ImageResult + */ + vtkImageData* getSubstractedImage(); + + /* + Get Image Size + */ + int getImageSize(); + + /* + constructing image substract + */ + void substract(vtkImageData* imageData1, vtkImageData* imageData2); + + + + //---------------------------------------------------------------------------------------- + // Attributes declaration + //---------------------------------------------------------------------------------------- + private: + /* + Substracted Image + */ + vtkImageData* imageResult; + /* + image size dimx*dimy*dimz + */ + int sizeImage; + /* + upper zero level for doing the Substraction + */ + int uZeroLevel; + /* + lower zero level for doing the Substraction + */ + int lZeroLevel; + /* + Color for the upper threshold + */ + int upperColor[3]; + /* + Color for the lower threshold + */ + int lowerColor[3]; + /* + Color for the medium threshold + */ + int mediumColor[3]; +}; + +class bbPackRecalage_EXPORT ImageSubstraction + : + public bbtk::AtomicBlackBox +{ + BBTK_BLACK_BOX_INTERFACE(ImageSubstraction,bbtk::AtomicBlackBox); + BBTK_DECLARE_INPUT(In1,vtkImageData*); + BBTK_DECLARE_INPUT(In2,vtkImageData*); + BBTK_DECLARE_INPUT(In3,int); + BBTK_DECLARE_INPUT(In4,int); + BBTK_DECLARE_INPUT(InU,std::vector); + BBTK_DECLARE_INPUT(InM,std::vector); + BBTK_DECLARE_INPUT(InL,std::vector); + BBTK_DECLARE_OUTPUT(Out,vtkImageData*); + BBTK_PROCESS(Process); + void Process(); +}; + +BBTK_BEGIN_DESCRIBE_BLACK_BOX(ImageSubstraction,bbtk::AtomicBlackBox); +BBTK_NAME("ImageSubstraction"); +BBTK_AUTHOR("jn.trillos44@uniandes.edu.co"); +BBTK_DESCRIPTION("Creates a image resulting from the substraction of the RGB values of 2 other images."); +BBTK_CATEGORY("__CATEGORY__"); +BBTK_INPUT(ImageSubstraction,In1,"Image 1",vtkImageData*,""); +BBTK_INPUT(ImageSubstraction,In2,"Image 2",vtkImageData*,""); +BBTK_INPUT(ImageSubstraction,In3,"Upper Zero Level (Value between 0 and 255)",int,""); +BBTK_INPUT(ImageSubstraction,In4,"Lower Zero Level (Value between 0 and 255)",int,""); +BBTK_INPUT(ImageSubstraction,InU,"Upper Level Color (RGB)",std::vector,""); +BBTK_INPUT(ImageSubstraction,InM,"Medium Level Color (RGB)",std::vector,""); +BBTK_INPUT(ImageSubstraction,InL,"Lower Level Color (RGB)",std::vector,""); +BBTK_OUTPUT(ImageSubstraction,Out,"Image Result",vtkImageData*,""); +BBTK_END_DESCRIBE_BLACK_BOX(ImageSubstraction); +} +// EO namespace bbCreaRecalage + +#endif // __bbCreaRecalageImageSubstraction_h_INCLUDED__ + diff --git a/PackRecalage/src/bbPackRecalageSurfaceCreator.cxx b/PackRecalage/src/bbPackRecalageSurfaceCreator.cxx new file mode 100644 index 0000000..4fe013f --- /dev/null +++ b/PackRecalage/src/bbPackRecalageSurfaceCreator.cxx @@ -0,0 +1,81 @@ +#include "bbPackRecalageSurfaceCreator.h" +#include "bbPackRecalagePackage.h" + +#include +#include +#include +#include + +#include "vtkActorCollection.h" + +namespace bbPackRecalage +{ + + + +BBTK_ADD_BLACK_BOX_TO_PACKAGE(PackRecalage,SurfaceCreator) +BBTK_BLACK_BOX_IMPLEMENTATION(SurfaceCreator,bbtk::AtomicBlackBox); +void SurfaceCreator::Process() +{ + surface1 = new Surface(bbGetInputImage1(),bbGetInputHeight1(),bbGetInputColor1()); + surface2 = new Surface(bbGetInputImage2(),bbGetInputHeight2(),bbGetInputColor2()); + + if(firsttime == true) + { + bbSetOutputOut1(surface1->getSurface()); + bbSetOutputOut2(surface2->getSurface()); + } + + if (bbGetInputRenderer()!=NULL) + { + firsttime = false; + + bbGetInputRenderer()->RemoveAllViewProps(); + + bbGetInputRenderer()->AddActor( surface1->getSurface()); + bbGetInputRenderer()->AddActor( surface2->getSurface()); + + bbGetInputRenderer()->Render(); + } +} +void SurfaceCreator::bbUserSetDefaultValues() +{ + +// SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX +// Here we initialize the input 'In' to 0 + firsttime=true; + bbSetInputImage1(NULL); + bbSetInputHeight1(0); + bbSetInputColor1(""); + bbSetInputImage2(NULL); + bbSetInputHeight2(0); + bbSetInputColor2(""); + bbSetInputRenderer(NULL); + +} +void SurfaceCreator::bbUserInitializeProcessing() +{ + +// THE INITIALIZATION METHOD BODY : +// Here does nothing +// but this is where you should allocate the internal/output pointers +// if any + + +} +void SurfaceCreator::bbUserFinalizeProcessing() +{ + +// THE FINALIZATION METHOD BODY : +// Here does nothing +// but this is where you should desallocate the internal/output pointers +// if any + + delete surface1; + delete surface2; + +} +} +// EO namespace bbCreaRecalage + + diff --git a/PackRecalage/src/bbPackRecalageSurfaceCreator.h b/PackRecalage/src/bbPackRecalageSurfaceCreator.h new file mode 100644 index 0000000..2487e7b --- /dev/null +++ b/PackRecalage/src/bbPackRecalageSurfaceCreator.h @@ -0,0 +1,58 @@ +#ifndef __bbPackRecalageSurfaceCreator_h_INCLUDED__ +#define __bbPackRecalageSurfaceCreator_h_INCLUDED__ +#include "bbPackRecalage_EXPORT.h" +#include "bbtkAtomicBlackBox.h" +#include "iostream" + +#include "Surface.h" + +#include "vtkActor.h" + +namespace bbPackRecalage +{ +class bbPackRecalage_EXPORT SurfaceCreator + : + public bbtk::AtomicBlackBox +{ + + bool firsttime; + + Surface *surface1; + Surface *surface2; + + vtkActorCollection *actors; + + BBTK_BLACK_BOX_INTERFACE(SurfaceCreator,bbtk::AtomicBlackBox); + BBTK_DECLARE_INPUT(Image1,vtkImageData*); + BBTK_DECLARE_INPUT(Image2,vtkImageData*); + BBTK_DECLARE_INPUT(Height1,int); + BBTK_DECLARE_INPUT(Height2,int); + BBTK_DECLARE_INPUT(Color1,std::string); + BBTK_DECLARE_INPUT(Color2,std::string); + BBTK_DECLARE_INPUT(Renderer,vtkRenderer*); + BBTK_DECLARE_OUTPUT(Out1,vtkProp3D*); + BBTK_DECLARE_OUTPUT(Out2,vtkProp3D*); + BBTK_PROCESS(Process); + void Process(); +}; + +BBTK_BEGIN_DESCRIBE_BLACK_BOX(SurfaceCreator,bbtk::AtomicBlackBox); +BBTK_NAME("SurfaceCreator"); +BBTK_AUTHOR("jn.trillos44@uniandes.edu.co"); +BBTK_DESCRIPTION("Creates a 3D surface from a 2D image in which the height of a specific point in the surface is defined by the RGB value in the same point of the image."); +BBTK_CATEGORY("__CATEGORY__"); +BBTK_INPUT(SurfaceCreator,Image1,"Original Image 1",vtkImageData*,""); +BBTK_INPUT(SurfaceCreator,Image2,"Original Image 2",vtkImageData*,""); +BBTK_INPUT(SurfaceCreator,Height1,"Maximun height of the first surface",int,""); +BBTK_INPUT(SurfaceCreator,Height2,"Maximun height of the second surface",int,""); +BBTK_INPUT(SurfaceCreator,Color1,"Color of the first surface",std::string,""); +BBTK_INPUT(SurfaceCreator,Color2,"Color of the second surface",std::string,""); +BBTK_INPUT(SurfaceCreator,Renderer,"3D scene in which to insert the surface",vtkRenderer*,""); +BBTK_OUTPUT(SurfaceCreator,Out1,"First 3D Surface",vtkProp3D*,""); +BBTK_OUTPUT(SurfaceCreator,Out2,"Second 3D Surface",vtkProp3D*,""); +BBTK_END_DESCRIBE_BLACK_BOX(SurfaceCreator); +} +// EO namespace bbCreaRecalage + +#endif // __bbCreaRecalageSurfaceCreator_h_INCLUDED__ + diff --git a/PackRecalage/src/bbPackRecalageTransparency.cxx b/PackRecalage/src/bbPackRecalageTransparency.cxx new file mode 100644 index 0000000..3a074a0 --- /dev/null +++ b/PackRecalage/src/bbPackRecalageTransparency.cxx @@ -0,0 +1,167 @@ +#include "bbPackRecalageTransparency.h" +#include "bbPackRecalagePackage.h" + +#include "vtkCamera.h" +#include "vtkImageActor.h" + +#include +#include +#include + +namespace bbPackRecalage +{ + + class MyTransparencyImage + { + public: + MyTransparencyImage(Transparency* box); + ~MyTransparencyImage(); + + void UpdateView(); + + private: + + //The box to use + Transparency *mBox; + + //Upper image (we apply the lookup table with transparency to this actor) + vtkImageActor *upperImageActor; + + //Base image (not to be modifyed) + vtkImageActor *baseImageActor; + + bool mUpdateCamera; + + }; + + /* + * Constructor + */ + MyTransparencyImage::MyTransparencyImage(Transparency* box) + : + mBox(box) + { + UpdateView(); + } + + /* + * Destructor + */ + MyTransparencyImage::~MyTransparencyImage() + { + //if(newImage != NULL) + { + //newImage->Delete(); + } + } + + /* + * Set image actors and apply lookup table + */ + void MyTransparencyImage::UpdateView() + { + if( ( mBox->bbGetInputImage1() == NULL ) ) + { + mUpdateCamera = true; + } + else if( (mBox->bbGetInputImage1() != NULL) && ( (mBox->bbGetInputStatus("Image1") != bbtk::UPTODATE) ) ) + { + mUpdateCamera = true; + } + if(mUpdateCamera) + { + //Lookup Table + vtkLookupTable *lookup = vtkLookupTable::New(); + lookup->SetAlphaRange(0, 1); + lookup->SetRange(0, 255); + lookup->SetValueRange(0.0, 255); + + //We assign a table of colors for the upper image, and set the white as transparent + for(int i = 0; i < 256; i++) + { + if( i >= 0 && i <= 50 ) + { + lookup->SetTableValue(i, 1.0, 0.0, 1.0, 1); + } + else if( i > 50 && i <= 100 ) + { + lookup->SetTableValue(i, 1.0, 0.0, 0.0, 1); + } + else if( i > 100 && i <= 150 ) + { + lookup->SetTableValue(i, 0.0, 1.0, 0.0, 1); + } + else if( i > 150 && i <= 200 ) + { + lookup->SetTableValue(i, 0.0, 0.0, 1.0, 1); + } + else if( i > 200 && i <= 250 ) + { + lookup->SetTableValue(i, 0.0, 1.0, 1.0, 1); + } + else if( i > 250 && i <= 254) + { + lookup->SetTableValue(i, 1.0, 1.0, 0.0, 1); + } + } + lookup->SetTableValue(255, 1.0, 1.0, 1.0, 0); + + lookup->SetSaturationRange(0.0, 0.0); + lookup->SetRampToLinear( ); + lookup->Build( ); + + vtkImageMapToColors *mapperImage = vtkImageMapToColors::New( ); + mapperImage->SetLookupTable( lookup ); + mapperImage->SetInput( mBox->bbGetInputImage2() ); + mapperImage->SetOutputFormatToRGBA( ); + + upperImageActor = vtkImageActor::New( ); + upperImageActor->SetInput( mapperImage->GetOutput() ); + upperImageActor->SetOpacity( 1 ); + + baseImageActor = vtkImageActor::New( ); + baseImageActor->SetInput( mBox->bbGetInputImage1() ); + + mBox->bbSetOutputActor1( (vtkProp3D*) baseImageActor ); + mBox->bbSetOutputActor2( (vtkProp3D*) upperImageActor ); + + } + } + +BBTK_ADD_BLACK_BOX_TO_PACKAGE(PackRecalage,Transparency) +BBTK_BLACK_BOX_IMPLEMENTATION(Transparency,bbtk::AtomicBlackBox); +void Transparency::Process() +{ + MyTransparencyImage* trs = new MyTransparencyImage( this ); +} +void Transparency::bbUserSetDefaultValues() +{ + bbSetInputImage1(NULL); + bbSetInputImage2(NULL); + bbSetOutputActor1(NULL); + bbSetOutputActor2(NULL); + +} +void Transparency::bbUserInitializeProcessing() +{ + +// THE INITIALIZATION METHOD BODY : +// Here does nothing +// but this is where you should allocate the internal/output pointers +// if any + + +} +void Transparency::bbUserFinalizeProcessing() +{ + +// THE FINALIZATION METHOD BODY : +// Here does nothing +// but this is where you should desallocate the internal/output pointers +// if any + +} +} +// EO namespace bbPackRecalage + + diff --git a/PackRecalage/src/bbPackRecalageTransparency.h b/PackRecalage/src/bbPackRecalageTransparency.h new file mode 100644 index 0000000..053b33a --- /dev/null +++ b/PackRecalage/src/bbPackRecalageTransparency.h @@ -0,0 +1,42 @@ +#ifndef __bbPackRecalageTransparency_h_INCLUDED__ +#define __bbPackRecalageTransparency_h_INCLUDED__ +#include "bbPackRecalage_EXPORT.h" +#include "bbtkAtomicBlackBox.h" +#include "iostream" + +#include "vtkImageData.h" +#include "vtkProp3D.h" + +#include "iostream" + +namespace bbPackRecalage +{ + +class bbPackRecalage_EXPORT Transparency + : + public bbtk::AtomicBlackBox +{ + BBTK_BLACK_BOX_INTERFACE(Transparency,bbtk::AtomicBlackBox); + BBTK_DECLARE_INPUT(Image1, vtkImageData*); + BBTK_DECLARE_INPUT(Image2, vtkImageData*); + BBTK_DECLARE_OUTPUT(Actor1, vtkProp3D*); + BBTK_DECLARE_OUTPUT(Actor2, vtkProp3D*); + BBTK_PROCESS(Process); + void Process(); +}; + +BBTK_BEGIN_DESCRIBE_BLACK_BOX(Transparency,bbtk::AtomicBlackBox); +BBTK_NAME("Transparency"); +BBTK_AUTHOR("c.perez75@uniandes.edu.co"); +BBTK_DESCRIPTION("Superposition of 2 images using transparency"); +BBTK_CATEGORY("__CATEGORY__"); +BBTK_INPUT(Transparency, Image1, "Input Image1", vtkImageData*, ""); +BBTK_INPUT(Transparency, Image2, "Input Image2", vtkImageData*, ""); +BBTK_OUTPUT(Transparency, Actor1, "Base image actor", vtkProp3D*, ""); +BBTK_OUTPUT(Transparency, Actor2, "Upper image actor", vtkProp3D*, ""); +BBTK_END_DESCRIBE_BLACK_BOX(Transparency); +} +// EO namespace bbPackRecalage + +#endif // __bbPackRecalageTransparency_h_INCLUDED__ + diff --git a/lib/Surface.cxx b/lib/Surface.cxx new file mode 100644 index 0000000..d1bf681 --- /dev/null +++ b/lib/Surface.cxx @@ -0,0 +1,954 @@ +#include "vtkImageData.h" +#include "vtkImageCast.h" +#include "vtkActor.h" +#include "vtkPoints.h" +#include "vtkPolyDataMapper.h" +#include "vtkPolyData.h" +#include "vtkProperty.h" +#include "vtkFloatArray.h" +#include "vtkType.h" +#include "vtkDataSetMapper.h" +#include "vtkCellArray.h" + +#include "Surface.h" + +#include +#include +#include +#include + +Surface::Surface(vtkImageData* imageData, int ZHeight, std::string iColor) +{ + surfaceResult= vtkActor::New(); + height=ZHeight; + color=iColor; + //Original image type this case is an unsigned char (3) + imageType=imageData->GetScalarType(); + + //substracting the image + createSurface(imageData); +} + +Surface::~Surface() +{ + if(surfaceResult!=NULL)surfaceResult->Delete(); +} + +//---------------------------------------------------------------------------- +// Methods +//---------------------------------------------------------------------------- + + +/* +Calculate the new image and save it in the attribute imageResult +it is used if the user had given the imageData +*/ +void Surface::createSurface(vtkImageData* imageData) +{ + //dimensions of the image (extent) + int ext[6]; + //setting the dimensionality (1d or 2d or 3d ) + int newDim[3]; + //image spacing + double spc[3]; + + //getting the information from the original image + imageData->GetSpacing(spc); + imageData->GetExtent(ext); + + //this a 2d image + newDim[0]=ext[1]-ext[0]+1; + newDim[1]=ext[3]-ext[2]+1; + newDim[2]=1;// in general it is ext[5]-ext[4]+1 + + + //initializing the image that represents the substracted image + //initialize(newDim,spc); + //Time to substract + surface(imageData); +} + +/* + Setting the values for the +*/ +void Surface::surface(vtkImageData* imageData) +{ + /* + images pointers + */ + vtkPoints* surfacePoints = vtkPoints::New(); + vtkCellArray* surfaceCells = vtkCellArray::New(); + int counter=0; + + if(imageType == VTK_CHAR) + { + // pointers to get into the image + char* dataImagePointer=NULL; + + // we start where the image starts + dataImagePointer=(char*)imageData->GetScalarPointer(0,0,0); + + /* + Image Size + */ + int ext[6]; + imageData->GetExtent(ext); + int sx,sy,sz; + sx=ext[1]-ext[0]+1; + sy=ext[3]-ext[2]+1; + sz=ext[5]-ext[4]+1; + + //----------------- + //A3 + //----------------- + //walking in the image + int i=0,j=0,k=0; + double sum1=0,sum2=0,sum3=0,sum4=0; + for(i=0;iGetScalarPointer(i,j,k); + + sum1=(int)(dataImagePointer[0]) + (int)(dataImagePointer[1]) + (int)(dataImagePointer[2]); + sum1=sum1/(3*VTK_CHAR_MAX); + + surfacePoints->InsertPoint(counter, i, j, sum1*height); + + counter ++; + } + } + } + + //This cycle creates the cells of the surface + int n =0; + for(i=0;iInsertNextCell(3); + surfaceCells->InsertCellPoint(n); + surfaceCells->InsertCellPoint(n+1); + surfaceCells->InsertCellPoint(n+sy+1); + + surfaceCells->InsertNextCell(3); + surfaceCells->InsertCellPoint(n); + surfaceCells->InsertCellPoint(n+sy+1); + surfaceCells->InsertCellPoint(n+sy); + + if(jGetScalarPointer(0,0,0); + + /* + Image Size + */ + int ext[6]; + imageData->GetExtent(ext); + int sx,sy,sz; + sx=ext[1]-ext[0]+1; + sy=ext[3]-ext[2]+1; + sz=ext[5]-ext[4]+1; + + //----------------- + //A3 + //----------------- + //walking in the image + int i=0,j=0,k=0; + double sum1=0,sum2=0,sum3=0,sum4=0; + for(i=0;iGetScalarPointer(i,j,k); + + sum1=(int)(dataImagePointer[0]) + (int)(dataImagePointer[1]) + (int)(dataImagePointer[2]); + sum1=sum1/(3*VTK_SIGNED_CHAR_MAX); + + surfacePoints->InsertPoint(counter, i, j, sum1*height); + + counter ++; + } + } + } + + //This cycle creates the cells of the surface + int n =0; + for(i=0;iInsertNextCell(3); + surfaceCells->InsertCellPoint(n); + surfaceCells->InsertCellPoint(n+1); + surfaceCells->InsertCellPoint(n+sy+1); + + surfaceCells->InsertNextCell(3); + surfaceCells->InsertCellPoint(n); + surfaceCells->InsertCellPoint(n+sy+1); + surfaceCells->InsertCellPoint(n+sy); + + if(jGetScalarPointer(0,0,0); + + /* + Image Size + */ + int ext[6]; + imageData->GetExtent(ext); + int sx,sy,sz; + sx=ext[1]-ext[0]+1; + sy=ext[3]-ext[2]+1; + sz=ext[5]-ext[4]+1; + + //----------------- + //A3 + //----------------- + //walking in the image + int i=0,j=0,k=0; + double sum1=0,sum2=0,sum3=0,sum4=0; + for(i=0;iGetScalarPointer(i,j,k); + + sum1=(int)(dataImagePointer[0]) + (int)(dataImagePointer[1]) + (int)(dataImagePointer[2]); + sum1=sum1/(3*VTK_UNSIGNED_CHAR_MAX); + + surfacePoints->InsertPoint(counter, i, j, sum1*height); + + counter ++; + } + } + } + + //This cycle creates the cells of the surface + int n =0; + for(i=0;iInsertNextCell(3); + surfaceCells->InsertCellPoint(n); + surfaceCells->InsertCellPoint(n+1); + surfaceCells->InsertCellPoint(n+sy+1); + + surfaceCells->InsertNextCell(3); + surfaceCells->InsertCellPoint(n); + surfaceCells->InsertCellPoint(n+sy+1); + surfaceCells->InsertCellPoint(n+sy); + + if(jGetScalarPointer(0,0,0); + + /* + Image Size + */ + int ext[6]; + imageData->GetExtent(ext); + int sx,sy,sz; + sx=ext[1]-ext[0]+1; + sy=ext[3]-ext[2]+1; + sz=ext[5]-ext[4]+1; + + //----------------- + //A3 + //----------------- + //walking in the image + int i=0,j=0,k=0; + double sum1=0,sum2=0,sum3=0,sum4=0; + for(i=0;iGetScalarPointer(i,j,k); + + sum1=(int)(dataImagePointer[0]) + (int)(dataImagePointer[1]) + (int)(dataImagePointer[2]); + sum1=sum1/(3*VTK_SHORT_MAX); + + surfacePoints->InsertPoint(counter, i, j, sum1*height); + + counter ++; + } + } + } + + //This cycle creates the cells of the surface + int n =0; + for(i=0;iInsertNextCell(3); + surfaceCells->InsertCellPoint(n); + surfaceCells->InsertCellPoint(n+1); + surfaceCells->InsertCellPoint(n+sy+1); + + surfaceCells->InsertNextCell(3); + surfaceCells->InsertCellPoint(n); + surfaceCells->InsertCellPoint(n+sy+1); + surfaceCells->InsertCellPoint(n+sy); + + if(jGetScalarPointer(0,0,0); + + /* + Image Size + */ + int ext[6]; + imageData->GetExtent(ext); + int sx,sy,sz; + sx=ext[1]-ext[0]+1; + sy=ext[3]-ext[2]+1; + sz=ext[5]-ext[4]+1; + + //----------------- + //A3 + //----------------- + //walking in the image + int i=0,j=0,k=0; + double sum1=0,sum2=0,sum3=0,sum4=0; + for(i=0;iGetScalarPointer(i,j,k); + + sum1=(int)(dataImagePointer[0]) + (int)(dataImagePointer[1]) + (int)(dataImagePointer[2]); + sum1=sum1/(3*VTK_UNSIGNED_SHORT_MAX); + + surfacePoints->InsertPoint(counter, i, j, sum1*height); + + counter ++; + } + } + } + + //This cycle creates the cells of the surface + int n =0; + for(i=0;iInsertNextCell(3); + surfaceCells->InsertCellPoint(n); + surfaceCells->InsertCellPoint(n+1); + surfaceCells->InsertCellPoint(n+sy+1); + + surfaceCells->InsertNextCell(3); + surfaceCells->InsertCellPoint(n); + surfaceCells->InsertCellPoint(n+sy+1); + surfaceCells->InsertCellPoint(n+sy); + + if(jGetScalarPointer(0,0,0); + + /* + Image Size + */ + int ext[6]; + imageData->GetExtent(ext); + int sx,sy,sz; + sx=ext[1]-ext[0]+1; + sy=ext[3]-ext[2]+1; + sz=ext[5]-ext[4]+1; + + //----------------- + //A3 + //----------------- + //walking in the image + int i=0,j=0,k=0; + double sum1=0,sum2=0,sum3=0,sum4=0; + for(i=0;iGetScalarPointer(i,j,k); + + sum1=(int)(dataImagePointer[0]) + (int)(dataImagePointer[1]) + (int)(dataImagePointer[2]); + sum1=sum1/(3*VTK_INT_MAX); + + surfacePoints->InsertPoint(counter, i, j, sum1*height); + + counter ++; + } + } + } + + //This cycle creates the cells of the surface + int n =0; + for(i=0;iInsertNextCell(3); + surfaceCells->InsertCellPoint(n); + surfaceCells->InsertCellPoint(n+1); + surfaceCells->InsertCellPoint(n+sy+1); + + surfaceCells->InsertNextCell(3); + surfaceCells->InsertCellPoint(n); + surfaceCells->InsertCellPoint(n+sy+1); + surfaceCells->InsertCellPoint(n+sy); + + if(jGetScalarPointer(0,0,0); + + /* + Image Size + */ + int ext[6]; + imageData->GetExtent(ext); + int sx,sy,sz; + sx=ext[1]-ext[0]+1; + sy=ext[3]-ext[2]+1; + sz=ext[5]-ext[4]+1; + + //----------------- + //A3 + //----------------- + //walking in the image + int i=0,j=0,k=0; + double sum1=0,sum2=0,sum3=0,sum4=0; + for(i=0;iGetScalarPointer(i,j,k); + + sum1=(int)(dataImagePointer[0]) + (int)(dataImagePointer[1]) + (int)(dataImagePointer[2]); + sum1=sum1/(3*VTK_UNSIGNED_INT_MAX); + + surfacePoints->InsertPoint(counter, i, j, sum1*height); + + counter ++; + } + } + } + + //This cycle creates the cells of the surface + int n =0; + for(i=0;iInsertNextCell(3); + surfaceCells->InsertCellPoint(n); + surfaceCells->InsertCellPoint(n+1); + surfaceCells->InsertCellPoint(n+sy+1); + + surfaceCells->InsertNextCell(3); + surfaceCells->InsertCellPoint(n); + surfaceCells->InsertCellPoint(n+sy+1); + surfaceCells->InsertCellPoint(n+sy); + + if(jGetScalarPointer(0,0,0); + + /* + Image Size + */ + int ext[6]; + imageData->GetExtent(ext); + int sx,sy,sz; + sx=ext[1]-ext[0]+1; + sy=ext[3]-ext[2]+1; + sz=ext[5]-ext[4]+1; + + //----------------- + //A3 + //----------------- + //walking in the image + int i=0,j=0,k=0; + double sum1=0,sum2=0,sum3=0,sum4=0; + for(i=0;iGetScalarPointer(i,j,k); + + sum1=(int)(dataImagePointer[0]) + (int)(dataImagePointer[1]) + (int)(dataImagePointer[2]); + sum1=sum1/(3*VTK_LONG_MAX); + + surfacePoints->InsertPoint(counter, i, j, sum1*height); + + counter ++; + } + } + } + + //This cycle creates the cells of the surface + int n =0; + for(i=0;iInsertNextCell(3); + surfaceCells->InsertCellPoint(n); + surfaceCells->InsertCellPoint(n+1); + surfaceCells->InsertCellPoint(n+sy+1); + + surfaceCells->InsertNextCell(3); + surfaceCells->InsertCellPoint(n); + surfaceCells->InsertCellPoint(n+sy+1); + surfaceCells->InsertCellPoint(n+sy); + + if(jGetScalarPointer(0,0,0); + + /* + Image Size + */ + int ext[6]; + imageData->GetExtent(ext); + int sx,sy,sz; + sx=ext[1]-ext[0]+1; + sy=ext[3]-ext[2]+1; + sz=ext[5]-ext[4]+1; + + //----------------- + //A3 + //----------------- + //walking in the image + int i=0,j=0,k=0; + double sum1=0,sum2=0,sum3=0,sum4=0; + for(i=0;iGetScalarPointer(i,j,k); + + sum1=(int)(dataImagePointer[0]) + (int)(dataImagePointer[1]) + (int)(dataImagePointer[2]); + sum1=sum1/(3*VTK_UNSIGNED_LONG_MAX); + + surfacePoints->InsertPoint(counter, i, j, sum1*height); + + counter ++; + } + } + } + + //This cycle creates the cells of the surface + int n =0; + for(i=0;iInsertNextCell(3); + surfaceCells->InsertCellPoint(n); + surfaceCells->InsertCellPoint(n+1); + surfaceCells->InsertCellPoint(n+sy+1); + + surfaceCells->InsertNextCell(3); + surfaceCells->InsertCellPoint(n); + surfaceCells->InsertCellPoint(n+sy+1); + surfaceCells->InsertCellPoint(n+sy); + + if(jGetScalarPointer(0,0,0); + + /* + Image Size + */ + int ext[6]; + imageData->GetExtent(ext); + int sx,sy,sz; + sx=ext[1]-ext[0]+1; + sy=ext[3]-ext[2]+1; + sz=ext[5]-ext[4]+1; + + //----------------- + //A3 + //----------------- + //walking in the image + int i=0,j=0,k=0; + double sum1=0,sum2=0,sum3=0,sum4=0; + for(i=0;iGetScalarPointer(i,j,k); + + sum1=(int)(dataImagePointer[0]) + (int)(dataImagePointer[1]) + (int)(dataImagePointer[2]); + sum1=sum1/(3*VTK_FLOAT_MAX); + + surfacePoints->InsertPoint(counter, i, j, sum1*height); + + counter ++; + } + } + } + + //This cycle creates the cells of the surface + int n =0; + for(i=0;iInsertNextCell(3); + surfaceCells->InsertCellPoint(n); + surfaceCells->InsertCellPoint(n+1); + surfaceCells->InsertCellPoint(n+sy+1); + + surfaceCells->InsertNextCell(3); + surfaceCells->InsertCellPoint(n); + surfaceCells->InsertCellPoint(n+sy+1); + surfaceCells->InsertCellPoint(n+sy); + + if(jGetScalarPointer(0,0,0); + + /* + Image Size + */ + int ext[6]; + imageData->GetExtent(ext); + int sx,sy,sz; + sx=ext[1]-ext[0]+1; + sy=ext[3]-ext[2]+1; + sz=ext[5]-ext[4]+1; + + //----------------- + //A3 + //----------------- + //walking in the image + int i=0,j=0,k=0; + double sum1=0,sum2=0,sum3=0,sum4=0; + for(i=0;iGetScalarPointer(i,j,k); + + sum1=(int)(dataImagePointer[0]) + (int)(dataImagePointer[1]) + (int)(dataImagePointer[2]); + sum1=sum1/(3*VTK_DOUBLE_MAX); + + surfacePoints->InsertPoint(counter, i, j, sum1*height); + + counter ++; + } + } + } + + //This cycle creates the cells of the surface + int n =0; + for(i=0;iInsertNextCell(3); + surfaceCells->InsertCellPoint(n); + surfaceCells->InsertCellPoint(n+1); + surfaceCells->InsertCellPoint(n+sy+1); + + surfaceCells->InsertNextCell(3); + surfaceCells->InsertCellPoint(n); + surfaceCells->InsertCellPoint(n+sy+1); + surfaceCells->InsertCellPoint(n+sy); + + if(jSetPolys(surfaceCells); + surfaceData->SetPoints(surfacePoints); + surfaceData->Update(); + + vtkPolyDataMapper* surfaceMapper = vtkPolyDataMapper::New(); + surfaceMapper->SetInput(surfaceData); + surfaceMapper->Update(); + + surfaceResult->SetMapper(surfaceMapper); + surfaceResult->GetProperty()->SetOpacity(1.0); + + if (color == "RED") + { + surfaceResult->GetProperty()->SetColor(1,0,0); + } + else if (color == "BLUE") + { + surfaceResult->GetProperty()->SetColor(0,0,1); + } + else if (color == "GREEN") + { + surfaceResult->GetProperty()->SetColor(0,1,0); + } + else + { + surfaceResult->GetProperty()->SetColor(1,1,1); + } +} +/* +Returns the filtered image +*/ +vtkActor* Surface::getSurface() +{ + return surfaceResult; +} \ No newline at end of file diff --git a/lib/Surface.h b/lib/Surface.h new file mode 100644 index 0000000..49b6724 --- /dev/null +++ b/lib/Surface.h @@ -0,0 +1,66 @@ +#include "vtkImageData.h" +#include "vtkProp3D.h" +#include "vtkRenderer.h" + +#include + +class Surface +{ + //---------------------------------------------------------------------------------------- + // Methods definition + //---------------------------------------------------------------------------------------- + public: + //-------------------------- + //Constructor & Destructor + //-------------------------- + Surface(vtkImageData* imageData, int ZHeight, std::string iColor); + ~Surface(); + //-------------------------- + //Methods + //-------------------------- + /* + getting ready the points + */ + void initialize(int dimensions[],double spacing[]); + /* + Calculate the new image and save it in the attribute imageResult + it is used if the user had given the imageData + */ + void createSurface(vtkImageData* imageData); + + /* + Returns the Surface + */ + vtkActor* getSurface(); + + /* + constructing image substract + */ + void surface(vtkImageData* imageData); + + + + //---------------------------------------------------------------------------------------- + // Attributes declaration + //---------------------------------------------------------------------------------------- + private: + /* + Surface + */ + vtkActor* surfaceResult; + + /* + Maximun height of the surface + */ + int height; + + /* + Color for the surface + */ + std::string color; + + /* + The type of image being viewed + */ + int imageType; +}; \ No newline at end of file diff --git a/lib/Transformer.cxx b/lib/Transformer.cxx new file mode 100644 index 0000000..de53958 --- /dev/null +++ b/lib/Transformer.cxx @@ -0,0 +1,101 @@ + +#include "Transformer.h" +#include "vtkMatrix4x4.h" + +/* + CONSTRUCTOR: Initializes the two points with empty vectors, the angle in 0. +*/ +Transformer::Transformer() +{ + std::vector empty (3,0); + _angle= 0; + _centerPoint=empty; + _scaleX=1; + _scaleY=1; + //If the transform already exists, we delete it before we create a new transform + //and set the matrix with the identity matrix + _transform= vtkTransform::New(); + vtkMatrix4x4 *_matrix = vtkMatrix4x4::New(); + _matrix->Identity(); + _transform->SetMatrix(_matrix); + +} + +/* + DESTRUCTOR +*/ +Transformer::~Transformer() +{ + //We delete the existing transform + if (_transform != NULL ) { _transform->Delete(); } +} + +/* + SETS A NEW TRANSFORM +*/ +void Transformer::SetTransform(vtkTransform *transform) +{ + _transform=transform; +} + +/* + SETS CENTER POINT +*/ +void Transformer::SetCenterPoint(std::vector point) +{ + _centerPoint=point; +} + +/* + SETS THE ANGLE +*/ +void Transformer::SetAngle(double angle) +{ + _angle=angle; +} + +/* + SETS THE X SCALE +*/ +void Transformer::SetScaleX(double scaleX) +{ + _scaleX=scaleX/100.0; +} + +/* + SETS THE Y SCALE +*/ +void Transformer::SetScaleY(double scaleY) +{ + _scaleY=scaleY/100.0; +} + +/* + SETS THE Y SCALE + */ +void Transformer::SetScaleZ(double scaleZ) +{ + _scaleZ=scaleZ/100.0; +} + + + +/* + GETS THE RESULTANT TRANSFORM +*/ +vtkTransform *Transformer::GetResult() +{ + return _transform; +} + +/* + MAKES THE TRANSFORMATIONS +*/ +void Transformer::Run() +{ + _transform->Identity(); + _transform->Translate(_centerPoint[0], _centerPoint[1], _centerPoint[2]); + _transform->Scale(_scaleX, _scaleY,_scaleZ); + _transform->RotateWXYZ(_angle, 0, 0, 1); + _transform->Update(); +} diff --git a/lib/Transformer.h b/lib/Transformer.h new file mode 100644 index 0000000..7af6494 --- /dev/null +++ b/lib/Transformer.h @@ -0,0 +1,30 @@ + +#ifndef _$PROJECT_NAME$SOURCE01_H_ +#define _$PROJECT_NAME$SOURCE01_H_ + +#include "vtkTransform.h" +#include + +class Transformer{ +public: + Transformer(); + ~Transformer(); + void SetTransform(vtkTransform *transform); + void SetCenterPoint(std::vector point); + void SetAngle(double angle); + void SetScaleX(double scaleX); + void SetScaleY(double scaleY); + void SetScaleZ(double scaleZ); + void Run(); + vtkTransform *GetResult(); +private: + std::vector _centerPoint; + double _angle; + double _scaleX; + double _scaleY; + double _scaleZ; + //vtkImageData *_image; + vtkTransform *_transform; +}; + +#endif diff --git a/lib/VectorMath.cxx b/lib/VectorMath.cxx new file mode 100644 index 0000000..1545154 --- /dev/null +++ b/lib/VectorMath.cxx @@ -0,0 +1,48 @@ +#include "VectorMath.h" + +VectorMath::VectorMath() +{ + //_math = vtkMath::new(); +} + +VectorMath::~VectorMath() +{ + if (_math != NULL ) { _math->Delete(); } +} + +void VectorMath::SetData(std::vector pointsX1, std::vector pointsX2, std::vector pointsY1, std::vector pointsY2, std::vector pointsZ1, std::vector pointsZ2) +{ + _pointx1a = pointsX1[0]; + _pointx1b = pointsX1[1]; + + _pointx2a = pointsX2[0]; + _pointx2b = pointsX2[1]; + + _pointy1a = pointsY1[0]; + _pointy1b = pointsY1[1]; + + _pointy2a = pointsY2[0]; + _pointy2b = pointsY2[1]; + + _pointz1a = pointsZ1[0]; + _pointz1b = pointsZ1[1]; + + _pointz2a = pointsZ2[0]; + _pointz2b = pointsZ2[1]; +} +/* + +int[3]* VectorMath::GetPoints() +{ + +} + +double[3]* VectorMath::GetScales() +{ + +} + +double VectorMath::GetAngle() +{ + +}*/ \ No newline at end of file diff --git a/lib/VectorMath.h b/lib/VectorMath.h new file mode 100644 index 0000000..b13aea2 --- /dev/null +++ b/lib/VectorMath.h @@ -0,0 +1,38 @@ +#ifndef _$PROJECT_NAME$SOURCE01_H_ +#define _$PROJECT_NAME$SOURCE01_H_ + +#include "vtkMath.h" +#include + +class VectorMath{ +public: + VectorMath(); + ~VectorMath(); + void SetData(std::vector pointsX1, std::vector pointsX2, std::vector pointsY1, std::vector pointsY2, std::vector pointsZ1, std::vector pointsZ2); + void Run(); + /* + int[3]* GetPoints(); + double[3]* GetScales(); + double GetAngle();*/ +private: + //float[3] _points; + + int _pointx1a; + int _pointx1b; + int _pointx2a; + int _pointx2b; + + int _pointy1a; + int _pointy1b; + int _pointy2a; + int _pointy2b; + + int _pointz1a; + int _pointz1b; + int _pointz2a; + int _pointz2b; + + vtkMath *_math; +}; + +#endif \ No newline at end of file