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 vtkRenderer *render = bbGetInputRenderer();
45 vtkImageData *img = bbGetInputIn();
46 vtkLinearTransform* transform = bbGetInputTransform();
51 if (bbGetInputLookupTable()==NULL)
53 //EED 2017-01-01 Migration VTK7
54 #if VTK_MAJOR_VERSION <= 5
55 imageactor->SetInput( img );
57 imageactor->SetInputData( img );
61 vtkLookupTable *table = vtkLookupTable::New();
62 table->SetRange(0, 1000); // image intensity range
63 table->SetValueRange(0.0, 1.0); // from black to white
64 table->SetSaturationRange(0.0, 0.0); // no color saturation
65 table->SetRampToLinear();
68 table->GetTableValue(0,rgba);
70 table->SetTableValue(0,rgba);
75 vtkLookupTable *table = vtkLookupTable::New();
76 table->SetTableRange (0, 2000);
77 table->SetHueRange (1, 0);
78 table->SetSaturationRange (1, 1);
79 table->SetValueRange (1, 1);
80 table->Build(); //effective built
84 vtkColorTransferFunction *table = vtkColorTransferFunction::New();
85 table->SetColorSpaceToHSV();
87 table->AddHSVSegment(0.0, 0.6, 1.0, 1.0,
89 table->SetNanColor(1.0, 0.0, 1.0);
93 printf("EED ImageActor::Process Warnning ***************************Not here this code *");
94 vtkLookupTable *table = vtkLookupTable::New();
95 table->SetNumberOfTableValues(1000);
96 table->SetRange(0, 1000);
100 for (int iLookTable = 0; iLookTable<500; iLookTable++)
102 table->GetTableValue( iLookTable, rgba1);
103 table->GetTableValue(1000-1-iLookTable, rgba2);
104 table->SetTableValue(1000-1-iLookTable , rgba1[0],rgba1[1],rgba1[2],rgba1[3]);
105 table->SetTableValue( iLookTable , rgba2[0],rgba2[1],rgba2[2],rgba2[3]);
108 table->GetTableValue(0,rgba);
110 table->SetTableValue(0,rgba);
112 vtkImageMapToColors *color = vtkImageMapToColors::New();
113 color->SetLookupTable( bbGetInputLookupTable() );
114 // color->SetLookupTable( table );
115 color->PassAlphaToOutputOn();
117 // imageshiftscale->SetInput( img );
118 // imageshiftscale->SetOutputScalarTypeToUnsignedChar();
120 // color->SetInput( imageshiftscale->GetOutput() );
123 //EED 2017-01-01 Migration VTK7
124 #if VTK_MAJOR_VERSION <= 5
125 color->SetInput( img );
127 imageactor->GetMapper()->SetInput( color->GetOutput() );
129 color->SetInputData( img );
131 imageactor->GetMapper()->SetInputData( color->GetOutput() );
133 imageactor->GetProperty()->SetInterpolationTypeToNearest();
134 imageactor->SetForceOpaque(true);
139 imageactor->SetUserTransform( transform );
143 // render->AddActor( imageactor );
145 bbSetOutputOut(imageactor);
149 if ((firsttime==true) && (bbGetInputRenderer()!=NULL ))
152 bbGetInputRenderer()->AddActor( imageactor );
154 imageactor->GetProperty()->SetOpacity( bbGetInputOpacity() );
155 bbSetOutputOut(imageactor);
158 void ImageActor::bbUserSetDefaultValues()
163 // bbSetInputType(0);
164 bbSetInputOpacity(1);
165 bbSetInputTransform(NULL);
166 bbSetInputRenderer(NULL);
167 bbSetInputLookupTable(NULL);
171 //-----------------------------------------------------------------
172 void ImageActor::bbUserInitializeProcessing()
174 imageactor = vtkImageActor::New();
175 imageshiftscale = vtkImageShiftScale::New();
178 //-----------------------------------------------------------------
179 void ImageActor::bbUserFinalizeProcessing()
183 //-----------------------------------------------------------------
185 // EO namespace bbcreaMaracasVisu