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();
53 if (bbGetInputLookupTable()==NULL)
55 imageactor->SetInput( img );
58 vtkLookupTable *table = vtkLookupTable::New();
59 table->SetRange(0, 1000); // image intensity range
60 table->SetValueRange(0.0, 1.0); // from black to white
61 table->SetSaturationRange(0.0, 0.0); // no color saturation
62 table->SetRampToLinear();
65 table->GetTableValue(0,rgba);
67 table->SetTableValue(0,rgba);
72 vtkLookupTable *table = vtkLookupTable::New();
73 table->SetTableRange (0, 2000);
74 table->SetHueRange (1, 0);
75 table->SetSaturationRange (1, 1);
76 table->SetValueRange (1, 1);
77 table->Build(); //effective built
81 vtkColorTransferFunction *table = vtkColorTransferFunction::New();
82 table->SetColorSpaceToHSV();
84 table->AddHSVSegment(0.0, 0.6, 1.0, 1.0,
86 table->SetNanColor(1.0, 0.0, 1.0);
90 printf("EED ImageActor::Process Warnning ***************************Not here this code *");
91 vtkLookupTable *table = vtkLookupTable::New();
92 table->SetNumberOfTableValues(1000);
93 table->SetRange(0, 1000);
97 for (int iLookTable = 0; iLookTable<500; iLookTable++)
99 table->GetTableValue( iLookTable, rgba1);
100 table->GetTableValue(1000-1-iLookTable, rgba2);
101 table->SetTableValue(1000-1-iLookTable , rgba1[0],rgba1[1],rgba1[2],rgba1[3]);
102 table->SetTableValue( iLookTable , rgba2[0],rgba2[1],rgba2[2],rgba2[3]);
105 table->GetTableValue(0,rgba);
107 table->SetTableValue(0,rgba);
109 vtkImageMapToColors *color = vtkImageMapToColors::New();
110 color->SetLookupTable( bbGetInputLookupTable() );
111 // color->SetLookupTable( table );
112 color->PassAlphaToOutputOn();
114 // imageshiftscale->SetInput( img );
115 // imageshiftscale->SetOutputScalarTypeToUnsignedChar();
117 // color->SetInput( imageshiftscale->GetOutput() );
118 color->SetInput( img );
120 imageactor->GetMapper()->SetInput( color->GetOutput() );
121 imageactor->GetProperty()->SetInterpolationTypeToNearest();
126 imageactor->SetUserTransform( transform );
130 // render->AddActor( imageactor );
132 bbSetOutputOut(imageactor);
137 if ((firsttime==true) && (bbGetInputRenderer()!=NULL ))
140 bbGetInputRenderer()->AddActor( imageactor );
143 imageactor->GetProperty()->SetOpacity( bbGetInputOpacity() );
144 bbSetOutputOut(imageactor);
147 printf("EED ImageActor::Process End\n");
151 void ImageActor::bbUserSetDefaultValues()
156 // bbSetInputType(0);
157 bbSetInputOpacity(1);
158 bbSetInputTransform(NULL);
159 bbSetInputRenderer(NULL);
160 bbSetInputLookupTable(NULL);
164 //-----------------------------------------------------------------
165 void ImageActor::bbUserInitializeProcessing()
167 imageactor = vtkImageActor::New();
168 imageshiftscale = vtkImageShiftScale::New();
171 //-----------------------------------------------------------------
172 void ImageActor::bbUserFinalizeProcessing()
176 //-----------------------------------------------------------------
178 // EO namespace bbcreaMaracasVisu