+++ /dev/null
-#include "bbtkStaticLecture.h"
-
-
- void bbtkStaticLecture::setPixelValue(int i, int j, int k, vtkImageData* img, double value)
- {
- //double rta;
- int scalar_type = img->GetScalarType();
- int* ext = img->GetExtent();
- if (i < ext[0])
- return;
- if (i > ext[1])
- return;
-
- if (j < ext[2])
- return;
- if (j > ext[3])
- return;
-
- if (k < ext[4])
- return;
- if (k > ext[5])
- return;
-
- switch (scalar_type)
- {
- case VTK_CHAR:
- char * ap2;
- ap2 = (char *) img->GetScalarPointer(i,j,k);
- *ap2 = (char) value;
- break;
- case VTK_UNSIGNED_CHAR:
- unsigned char * ap3;
- ap3 = (unsigned char *) img->GetScalarPointer(i,j,k);
- *ap3 = (unsigned char) value;
- break;
- case VTK_SHORT:
- short * ap4;
- ap4 = (short *) img->GetScalarPointer(i,j,k);
- *ap4 = (short) value;
- break;
- case VTK_UNSIGNED_SHORT:
- unsigned short * ap5;
- ap5 = (unsigned short *) img->GetScalarPointer(i,j,k);
- *ap5 = (unsigned short) value;
- break;
- case VTK_INT:
- int * ap6;
- ap6 = (int *) img->GetScalarPointer(i,j,k);
- *ap6 = (int) value;
- break;
- case VTK_UNSIGNED_INT:
- unsigned int * ap7;
- ap7 = (unsigned int *) img->GetScalarPointer(i,j,k);
- *ap7 = (unsigned int) value;
- break;
- case VTK_LONG:
- long * ap8;
- ap8 = (long *) img->GetScalarPointer(i,j,k);
- *ap8 = (long) value;
- break;
- case VTK_UNSIGNED_LONG:
- unsigned long * ap9;
- ap9 = (unsigned long *) img->GetScalarPointer(i,j,k);
- *ap9 = (unsigned long) value;
- break;
- case VTK_FLOAT:
- float * ap10;
- ap10 = (float *) img->GetScalarPointer(i,j,k);
- *ap10 = (float) value;
- break;
- case VTK_DOUBLE:
- double * ap11;
- ap11 = (double *) img->GetScalarPointer(i,j,k);
- *ap11 = (double) value;
- break;
- }
- }
- double bbtkStaticLecture::getPixelValue(int i, int j, int k, vtkImageData* img)
- {
- double rta;
- int scalar_type = img->GetScalarType();
- int* ext = img->GetExtent();
- if (i < ext[0])
- i=ext[0];
- if (i > ext[1])
- i=ext[1];
-
- if (j < ext[2])
- j=ext[2];
- if (j > ext[3])
- j=ext[3];
-
- if (k < ext[4])
- k=ext[4];
- if (k > ext[5])
- k=ext[5];
-
- switch (scalar_type)
- {
- case VTK_CHAR:
- char * ap2;
- ap2 = (char *) img->GetScalarPointer(i,j,k);
- rta = (double) *ap2;
- break;
- case VTK_UNSIGNED_CHAR:
- unsigned char * ap3;
- ap3 = (unsigned char *) img->GetScalarPointer(i,j,k);
- rta = (double) *ap3;
- break;
- case VTK_SHORT:
- short * ap4;
- ap4 = (short *) img->GetScalarPointer(i,j,k);
- rta = (double) *ap4;
- break;
- case VTK_UNSIGNED_SHORT:
- unsigned short * ap5;
- ap5 = (unsigned short *) img->GetScalarPointer(i,j,k);
- rta = (double) *ap5;
- break;
- case VTK_INT:
- int * ap6;
- ap6 = (int *) img->GetScalarPointer(i,j,k);
- rta = (double) *ap6;
- break;
- case VTK_UNSIGNED_INT:
- unsigned int * ap7;
- ap7 = (unsigned int *) img->GetScalarPointer(i,j,k);
- rta = (double) *ap7;
- break;
- case VTK_LONG:
- long * ap8;
- ap8 = (long *) img->GetScalarPointer(i,j,k);
- rta = (double) *ap8;
- break;
- case VTK_UNSIGNED_LONG:
- unsigned long * ap9;
- ap9 = (unsigned long *) img->GetScalarPointer(i,j,k);
- rta = (double) *ap9;
- break;
- case VTK_FLOAT:
- float * ap10;
- ap10 = (float *) img->GetScalarPointer(i,j,k);
- rta = (double) *ap10;
- break;
- case VTK_DOUBLE:
- double * ap11;
- ap11 = (double *) img->GetScalarPointer(i,j,k);
- rta = (double) *ap11;
- break;
- }
- return rta;
- }
+++ /dev/null
-#ifndef __bbtkStaticLecture__h__
-#define __bbtkStaticLecture__h__
-
-#include <vtkType.h>
-#include <vtkImageData.h>
-
-class bbtkStaticLecture
-{
-public:
- void setPixelValue(int i, int j, int k, vtkImageData* img, double value);
- double getPixelValue(int i, int j, int k, vtkImageData* img);
-};
-
-#endif
+++ /dev/null
-#include "bbTranslationElementTypeChanger.h"
-#include "bbTranslationPackage.h"
-namespace bbTranslation
-{
-
-BBTK_ADD_BLACK_BOX_TO_PACKAGE(Translation,ElementTypeChanger)
-BBTK_BLACK_BOX_IMPLEMENTATION(ElementTypeChanger,bbtk::AtomicBlackBox);
-void ElementTypeChanger::Process()
-{
- vtkImageData* ans = NULL;
- vtkImageData* src = bbGetInputIn();
- if (src == NULL){
- return;
- }
-
- if (bbGetInputIsFLOATToUSHORT())
- {
- ans = myOwnCast(src, bbGetInputInType());
- }
- else
- {
- caster->SetOutputScalarType(bbGetInputInType());
- //caster->SetOutputScalarTypeToUnsignedShort();
- caster->SetClampOverflow(bbGetInputClampOverflow());
- caster->SetInput(src);
- caster->Update();
- ans = caster->GetOutput();
-
- double typeMin = ans->GetScalarTypeMin();
- double typeMax = ans->GetScalarTypeMax();
-
- std::cout << typeMin << "," << typeMax << std::endl;
-
- /*
- vtkStructuredPoints* stPoints = vtkStructuredPoints::New( );
- vtkImageChangeInformation* change = vtkImageChangeInformation::New();
-
- vtkDataArray* apt2 = filtro->GetOutput()->GetPointData()->GetScalars();
-
- stPoints->GetPointData( )->SetScalars(apt2);
- stPoints->SetDimensions( sizeIma, sizeIma, 1 );
- stPoints->SetScalarType( volume->GetScalarType( ) );
- stPoints->Update();
-
- change->SetInput( stPoints );
- change->Update(); //important
-
- return change->GetOutput();
- */
-
- }
- bbSetOutputOut(ans);
-}
-vtkImageData* ElementTypeChanger::myOwnCast(vtkImageData* original, int type)
-{
- vtkImageData* final = vtkImageData::New();
-
- int ext[6];
- int newDim[3];
- double space[3];
- double origin[3];
-
- original->GetSpacing(space);
- original->GetExtent(ext);
- original->GetOrigin(origin);
- original->GetDimensions(newDim);
-
- final->SetScalarTypeToUnsignedShort();
-
- final->SetSpacing(space);
- final->SetDimensions(newDim);
- final->SetOrigin(origin);
-
- final->AllocateScalars();
- final->Update();
-
- float * ap1;
- unsigned short * ap2;
-
- float max_value = 0;
- float max_value2 = 0;
- //double min_value = GetScalarTypeMin();
- //double max_value = GetScalarTypeMax();
- for (int i=0; i<newDim[0]; i++){
- for (int j=0; j<newDim[1]; j++){
- for (int k=0; k<newDim[2]; k++){
- ap1 = (float *) original->GetScalarPointer(i,j,k);
-
- ap2 = (unsigned short *) final->GetScalarPointer(i,j,k);
- *ap2 = (((float) *ap1)*(bbGetInputScale()));
- }
- }
- }
-
- return final;
-}
-
-void ElementTypeChanger::bbUserSetDefaultValues()
-{
-
- bbSetInputClampOverflow(1);
- bbSetInputIn(NULL);
- bbSetInputScale(1);
- bbSetOutputOut(NULL);
- bbSetInputInType(VTK_UNSIGNED_SHORT);
- bbSetInputIsFLOATToUSHORT(false);
- caster = vtkImageCast::New();
-
-}
-void ElementTypeChanger::bbUserInitializeProcessing()
-{
-
-// THE INITIALIZATION METHOD BODY :
-// Here does nothing
-// but this is where you should allocate the internal/output pointers
-// if any
-
-
-}
-void ElementTypeChanger::bbUserFinalizeProcessing()
-{
-
-// THE FINALIZATION METHOD BODY :
-// Here does nothing
-// but this is where you should desallocate the internal/output pointers
-// if any
-
-}
-}
-// EO namespace bbTranslation
-
-
Program: bbtk
Module: $RCSfile: bbvtkSegmentationConnectivity.cxx,v $
Language: C++
- Date: $Date: 2010/04/08 14:37:59 $
- Version: $Revision: 1.6 $
+ Date: $Date: 2011/06/16 12:28:43 $
+ Version: $Revision: 1.7 $
=========================================================================*/
/* ---------------------------------------------------------------------
thresh2->Update();
cast2->Update();
connect2->RemoveAllSeeds ();
- connect2->AddSeed( bbGetInputPositionXYZ()[0] , bbGetInputPositionXYZ()[1] , bbGetInputPositionXYZ()[2] );
- connect2->Update();
- cast4->Update();
-
- bbSetOutputOut(cast4->GetOutput() );
+
+ int x = bbGetInputPositionXYZ()[0];
+ int y = bbGetInputPositionXYZ()[1];
+ int z = bbGetInputPositionXYZ()[2];
+
+ int ext[6];
+ imagedata->GetWholeExtent(ext);
+ int maxx = ext[1]-ext[0]+1;
+ int maxy = ext[3]-ext[2]+1;
+ int maxz = ext[5]-ext[4]+1;
+ if ( x<0 ) { printf("Warnnig bbtk::vtk::SegmentationConnectivity::DoProcess limites of the image out of range x: %d -> 0 \n",x ); x=0; }
+ if ( y<0 ) { printf("Warnnig bbtk::vtk::SegmentationConnectivity::DoProcess limites of the image out of range y: %d -> 0 \n",y ); y=0;}
+ if ( z<0 ) { printf("Warnnig bbtk::vtk::SegmentationConnectivity::DoProcess limites of the image out of range z: %d -> 0 \n",z ); z=0;}
+
+ if ( x>=maxx ) { printf("Warnnig bbtk::vtk::SegmentationConnectivity::DoProcess limites of the image out of range x: %d -> %d \n",x, maxx-1 ); x=maxx-1; }
+ if ( y>=maxy ) { printf("Warnnig bbtk::vtk::SegmentationConnectivity::DoProcess limites of the image out of range y: %d -> %d \n",y, maxy-1 ); y=maxy-1; }
+ if ( z>=maxz ) { printf("Warnnig bbtk::vtk::SegmentationConnectivity::DoProcess limites of the image out of range z: %d -> %d \n",y, maxz-1 ); z=maxz-1; }
+
+ connect2->AddSeed( x,y,z );
+ connect2->Update();
+ cast4->Update();
+ bbSetOutputOut(cast4->GetOutput() );
}
}// EO namespace bbvtk