1 /*# ---------------------------------------------------------------------
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9 # This software is governed by the CeCILL-B license under French law and
10 # abiding by the rules of distribution of free software. You can use,
11 # modify and/ or redistribute the software under the terms of the CeCILL-B
12 # license as circulated by CEA, CNRS and INRIA at the following URL
13 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 # or in the file LICENSE.txt.
16 # As a counterpart to the access to the source code and rights to copy,
17 # modify and redistribute granted by the license, users are provided only
18 # with a limited warranty and the software's author, the holder of the
19 # economic rights, and the successive licensors have only limited
22 # The fact that you are presently reading this means that you have had
23 # knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
26 #include "bbmaracasvisuImageActor.h"
27 #include "bbcreaMaracasVisuPackage.h"
29 #include "vtkImageShiftScale.h"
30 #include <vtkLookupTable.h>
31 #include <vtkColorTransferFunction.h>
32 #include <vtkImageMapToColors.h>
33 #include <vtkImageMapper3D.h>
34 #include <vtkImageProperty.h>
36 namespace bbcreaMaracasVisu
39 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,ImageActor)
40 BBTK_BLACK_BOX_IMPLEMENTATION(ImageActor,bbtk::AtomicBlackBox);
41 void ImageActor::Process()
44 printf("EED ImageActor::Process Start\n");
47 vtkRenderer *render = bbGetInputRenderer();
48 vtkImageData *img = bbGetInputIn();
49 vtkLinearTransform* transform = bbGetInputTransform();
54 if (bbGetInputLookupTable()==NULL)
56 //EED 2017-01-01 Migration VTK7
57 #if VTK_MAJOR_VERSION <= 5
58 imageactor->SetInput( img );
60 imageactor->SetInputData( img );
64 vtkLookupTable *table = vtkLookupTable::New();
65 table->SetRange(0, 1000); // image intensity range
66 table->SetValueRange(0.0, 1.0); // from black to white
67 table->SetSaturationRange(0.0, 0.0); // no color saturation
68 table->SetRampToLinear();
71 table->GetTableValue(0,rgba);
73 table->SetTableValue(0,rgba);
78 vtkLookupTable *table = vtkLookupTable::New();
79 table->SetTableRange (0, 2000);
80 table->SetHueRange (1, 0);
81 table->SetSaturationRange (1, 1);
82 table->SetValueRange (1, 1);
83 table->Build(); //effective built
87 vtkColorTransferFunction *table = vtkColorTransferFunction::New();
88 table->SetColorSpaceToHSV();
90 table->AddHSVSegment(0.0, 0.6, 1.0, 1.0,
92 table->SetNanColor(1.0, 0.0, 1.0);
96 printf("EED ImageActor::Process Warnning ***************************Not here this code *");
97 vtkLookupTable *table = vtkLookupTable::New();
98 table->SetNumberOfTableValues(1000);
99 table->SetRange(0, 1000);
103 for (int iLookTable = 0; iLookTable<500; iLookTable++)
105 table->GetTableValue( iLookTable, rgba1);
106 table->GetTableValue(1000-1-iLookTable, rgba2);
107 table->SetTableValue(1000-1-iLookTable , rgba1[0],rgba1[1],rgba1[2],rgba1[3]);
108 table->SetTableValue( iLookTable , rgba2[0],rgba2[1],rgba2[2],rgba2[3]);
111 table->GetTableValue(0,rgba);
113 table->SetTableValue(0,rgba);
115 vtkImageMapToColors *color = vtkImageMapToColors::New();
116 color->SetLookupTable( bbGetInputLookupTable() );
117 // color->SetLookupTable( table );
118 color->PassAlphaToOutputOn();
120 // imageshiftscale->SetInput( img );
121 // imageshiftscale->SetOutputScalarTypeToUnsignedChar();
123 // color->SetInput( imageshiftscale->GetOutput() );
126 //EED 2017-01-01 Migration VTK7
127 #if VTK_MAJOR_VERSION <= 5
128 color->SetInput( img );
130 imageactor->GetMapper()->SetInput( color->GetOutput() );
132 color->SetInputData( img );
133 imageactor->GetMapper()->SetInputData( color->GetOutput() );
135 imageactor->GetProperty()->SetInterpolationTypeToNearest();
140 imageactor->SetUserTransform( transform );
144 // render->AddActor( imageactor );
146 bbSetOutputOut(imageactor);
151 if ((firsttime==true) && (bbGetInputRenderer()!=NULL ))
154 bbGetInputRenderer()->AddActor( imageactor );
157 imageactor->GetProperty()->SetOpacity( bbGetInputOpacity() );
158 bbSetOutputOut(imageactor);
161 printf("EED ImageActor::Process End\n");
165 void ImageActor::bbUserSetDefaultValues()
170 // bbSetInputType(0);
171 bbSetInputOpacity(1);
172 bbSetInputTransform(NULL);
173 bbSetInputRenderer(NULL);
174 bbSetInputLookupTable(NULL);
178 //-----------------------------------------------------------------
179 void ImageActor::bbUserInitializeProcessing()
181 imageactor = vtkImageActor::New();
182 imageshiftscale = vtkImageShiftScale::New();
185 //-----------------------------------------------------------------
186 void ImageActor::bbUserFinalizeProcessing()
190 //-----------------------------------------------------------------
192 // EO namespace bbcreaMaracasVisu