- int i,j,k;
- for (i=0; i<dim[0]; i++)
- {
- for (j=0; j<dim[1]; j++)
- {
- for (k=0; k<dim[2]; k++)
- {
- value = bbGetInputIn()->GetScalarComponentAsDouble(i,j,k,0);
-
- if (bbGetInputType()==0) // Rescale Slope/Intercept
- {
- newValue = value*A+B;
- } // if type 0
-
- if (bbGetInputType()==1) // Invert
- {
- newValue = value*(-1) + (range0plusrange1);
- } // if type 1
-
- if (bbGetInputType()==2) // Redimension
- {
- newValue = ((value-range[0])/difrange)*newdifrange + A;
- } // if type 2
-
- if (bbGetInputType()==3) // Invert redimension
- {
- newValue = ((value*(-1)+range[1])/difrange)*newdifrange + A;
- } // if type 3
-
- imageoutput->SetScalarComponentFromDouble (i,j,k, 0, newValue);
- } // for k
- } // for j
- } // for i
-
- bbSetOutputOut(imageoutput);
- } // if
+ double shift;
+ double scale;
+
+ if (bbGetInputType()==0) // Rescale Slope/Intercept
+ {
+ // newValue = value*A+B;
+ scale = A;
+ shift = B;
+ } // if type 0
+
+ if (bbGetInputType()==1) // Invert
+ {
+ // newValue = value*(-1) + (range0plusrange1);
+ scale=-1;
+ shift=range0plusrange1;
+ } // if type 1
+
+ if (bbGetInputType()==2) // Redimension
+ {
+ // newValue = ((value-range[0])/difrange)*newdifrange + A;
+ scale=newdifrange/difrange;
+ shift= A - (range[0]*newdifrange/difrange);
+ } // if type 2
+
+ if (bbGetInputType()==3) // Invert redimension
+ {
+ // newValue = ((value*(-1)+range[1])/difrange)*newdifrange + A;
+ scale=-newdifrange/difrange;
+ shift= A + (range[1]*newdifrange/difrange);
+ } // if type 3
+
+ filter1->SetInput( bbGetInputIn() );
+ filter1->SetOutputScalarType( VTK_DOUBLE );
+ filter1->SetShift( 0 );
+ filter1->SetScale( scale );
+
+ filter2->SetInput( filter1->GetOutput() );
+ filter2->SetOutputScalarType( outputformat );
+ filter2->SetShift( shift );
+ filter2->SetScale( 1 );
+
+ mchange->SetInput( filter2->GetOutput() );
+ mchange->SetExtentTranslation( -ext[0], -ext[2], -ext[4] );
+ mchange->SetOutputSpacing (spc);
+ mchange->Update(); //important
+ bbSetOutputOut( mchange->GetOutput() );
+
+ } else {
+ bbSetOutputOut( NULL );
+ } // if bbGetInputIn