}
-#endif /* _DLL_H_ */
+#endif // _BBTKSIMPLEUTILITIES_H_
#include "bbtkStaticLecture.h"
+#include <string>
+
+int bbtkStaticLecture::GetTypeFormat( std::string formatStr , vtkImageData* image )
+{
+ int outputformat = VTK_UNSIGNED_CHAR;
+ if (formatStr=="SAME")
+ {
+ if (image!=NULL) outputformat = image->GetScalarType();
+ }
+ else if (formatStr=="VTK_BIT") outputformat = VTK_BIT; // 1
+ else if (formatStr=="VTK_CHAR") outputformat = VTK_CHAR; // 2
+ else if (formatStr=="VTK_SIGNED_CHAR") outputformat = VTK_SIGNED_CHAR; // 15
+ else if (formatStr=="VTK_UNSIGNED_CHAR") outputformat = VTK_UNSIGNED_CHAR; // 3
+ else if (formatStr=="VTK_SHORT") outputformat = VTK_SHORT; // 4
+ else if (formatStr=="VTK_UNSIGNED_SHORT") outputformat = VTK_UNSIGNED_SHORT; // 5
+ else if (formatStr=="VTK_INT") outputformat = VTK_INT; // 6
+ else if (formatStr=="VTK_UNSIGNED_INT") outputformat = VTK_UNSIGNED_INT; // 7
+ else if (formatStr=="VTK_LONG") outputformat = VTK_LONG; // 8
+ else if (formatStr=="VTK_UNSIGNED_LONG") outputformat = VTK_UNSIGNED_LONG; // 9
+ else if (formatStr=="VTK_FLOAT") outputformat = VTK_FLOAT; // 10
+ else if (formatStr=="VTK_DOUBLE") outputformat = VTK_DOUBLE; // 11
+ else if (formatStr=="MET_CHAR") outputformat = VTK_CHAR; // 2
+ else if (formatStr=="MET_UCHAR") outputformat = VTK_UNSIGNED_CHAR; // 3
+ else if (formatStr=="MET_SHORT") outputformat = VTK_SHORT; // 4
+ else if (formatStr=="MET_USHORT") outputformat = VTK_UNSIGNED_SHORT; // 5
+ else if (formatStr=="MET_SHORT") outputformat = VTK_SHORT; // 4
+ else if (formatStr=="MET_FLOAT") outputformat = VTK_FLOAT; // 10
+ else if (formatStr=="MET_DOUBLE") outputformat = VTK_DOUBLE; // 11
+
+ return outputformat;
+}
+
+
void bbtkStaticLecture::setPixelValue(int i, int j, int k, vtkImageData* img, double value)
{
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);
+ static int GetTypeFormat( std::string formatStr , vtkImageData* image );
+ void setPixelValue(int i, int j, int k, vtkImageData* img, double value);
+ double getPixelValue(int i, int j, int k, vtkImageData* img);
};
#endif
#include "bbvtkRescaleSlopeIntercept.h"
#include "bbvtkPackage.h"
+#include "bbtkStaticLecture.h"
namespace bbvtk
{
if (bbGetInputIn()!=0)
{
- if (bbGetInputOutputFormat()=="SAME") outputformat = bbGetInputIn()->GetScalarType();
- else if (bbGetInputOutputFormat()=="VTK_BIT") outputformat = VTK_BIT; // 1
- else if (bbGetInputOutputFormat()=="VTK_CHAR") outputformat = VTK_CHAR; // 2
- else if (bbGetInputOutputFormat()=="VTK_SIGNED_CHAR") outputformat = VTK_SIGNED_CHAR; // 15
- else if (bbGetInputOutputFormat()=="VTK_UNSIGNED_CHAR") outputformat = VTK_UNSIGNED_CHAR; // 3
- else if (bbGetInputOutputFormat()=="VTK_SHORT") outputformat = VTK_SHORT; // 4
- else if (bbGetInputOutputFormat()=="VTK_UNSIGNED_SHORT") outputformat = VTK_UNSIGNED_SHORT; // 5
- else if (bbGetInputOutputFormat()=="VTK_INT") outputformat = VTK_INT; // 6
- else if (bbGetInputOutputFormat()=="VTK_UNSIGNED_INT") outputformat = VTK_UNSIGNED_INT; // 7
- else if (bbGetInputOutputFormat()=="VTK_LONG") outputformat = VTK_LONG; // 8
- else if (bbGetInputOutputFormat()=="VTK_UNSIGNED_LONG") outputformat = VTK_UNSIGNED_LONG; // 9
- else if (bbGetInputOutputFormat()=="VTK_FLOAT") outputformat = VTK_FLOAT; // 10
- else if (bbGetInputOutputFormat()=="VTK_DOUBLE") outputformat = VTK_DOUBLE; // 11
+
+
+ int outputformat = bbtkStaticLecture::GetTypeFormat( bbGetInputOutputFormat() , bbGetInputIn() );
bbGetInputIn()->GetScalarRange(range);
BBTK_DECLARE_OUTPUT(Out,vtkImageData*);
BBTK_PROCESS(Process);
void Process();
-
- int outputformat;
+
vtkImageShiftScale *filter1;
vtkImageShiftScale *filter2;
vtkImageChangeInformation *mchange;
#include "bbvtkSegmentationConnectivity.h"
#include "bbvtkPackage.h"
+#include "bbtkStaticLecture.h"
+
namespace bbvtk
{
BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,SegmentationConnectivity);
void SegmentationConnectivity::bbUserSetDefaultValues()
{
thresh2 = NULL;
- cast2 = NULL;
+// cast2 = NULL;
connect2 = NULL;
cast4 = NULL;
threshold.push_back(0);
bbSetInputThresholdMinMax(threshold);
bbSetOutputOut(NULL);
+
+ bbSetInputOutputFormat("SAME");
+ bbSetInputValue(255);
+
+
}
// --------------------------------------------------------------
void SegmentationConnectivity::bbUserInitializeProcessing()
{
+
+ thresh2 = vtkImageThreshold::New();
+ thresh2->SetInValue(255);
+ thresh2->SetOutputScalarTypeToUnsignedChar();
+ connect2 = vtkImageSeedConnectivity::New();
+ connect2->SetInput(thresh2->GetOutput());
+ connect2->SetInputConnectValue(255);
+ connect2->SetOutputConnectedValue( 255 );
+ connect2->SetOutputUnconnectedValue(0);
+ cast4 = vtkImageCast::New();
+ cast4->SetInput(connect2->GetOutput());
+
+// EED 2016 06 15
+
+/*
thresh2 = vtkImageThreshold::New();
thresh2->SetInValue(255);
thresh2->SetOutputScalarTypeToUnsignedShort();
cast4 = vtkImageCast::New();
cast4->SetInput(connect2->GetOutput());
cast4->SetOutputScalarTypeToUnsignedShort();
+*/
+
}
// --------------------------------------------------------------
thresh2->Delete();
thresh2=NULL;
}
- if (cast2!=NULL)
- {
- cast2->Delete();
- cast2=NULL;
- }
+// if (cast2!=NULL)
+// {
+// cast2->Delete();
+// cast2=NULL;
+// }
if (connect2!=NULL)
{
connect2->Delete();
}
}
+
+
+
// --------------------------------------------------------------
void SegmentationConnectivity::DoProcess()
{
+ int outputformat = bbtkStaticLecture::GetTypeFormat( bbGetInputOutputFormat() , bbGetInputIn() );
+
+
+
vtkImageData *imagedata = bbGetInputIn();
imagedata->UpdateInformation();
imagedata->SetUpdateExtent(imagedata->GetWholeExtent());
thresh2->ThresholdBetween(bbGetInputThresholdMinMax()[0], bbGetInputThresholdMinMax()[1]);
thresh2->Modified();
thresh2->Update();
- cast2->Modified();
- cast2->Update();
+// EED 2016 06 15
+// cast2->Modified();
+// cast2->Update();
connect2->RemoveAllSeeds ();
int x = bbGetInputPositionXYZ()[0];
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->SetOutputConnectedValue( bbGetInputValue() );
+ cast4->SetOutputScalarType( outputformat );
+
connect2->Modified();
connect2->Update();
cast4->Update();
BBTK_DECLARE_INPUT(In,vtkImageData *);
BBTK_DECLARE_INPUT(PositionXYZ,std::vector<int>);
BBTK_DECLARE_INPUT(ThresholdMinMax,std::vector<int>);
+ BBTK_DECLARE_INPUT(Value,unsigned char);
+ BBTK_DECLARE_INPUT( OutputFormat , std::string );
BBTK_DECLARE_OUTPUT(Out,vtkImageData *);
BBTK_PROCESS(DoProcess);
void DoProcess();
protected:
private:
- vtkImageCast *cast2;
+// vtkImageCast *cast2;
vtkImageCast *cast4; // binary segmentation result
vtkImageThreshold *thresh2;
vtkImageSeedConnectivity *connect2;
};
BBTK_BEGIN_DESCRIBE_BLACK_BOX(SegmentationConnectivity,bbtk::AtomicBlackBox);
- BBTK_NAME("SegmentationConnectivity");
- BBTK_AUTHOR("eduardo.davila [at] creatis.insa-lyon.fr");
- BBTK_DESCRIPTION("Segmentation with min max threshold and connectivity");
- BBTK_INPUT(SegmentationConnectivity,In,"Input image",vtkImageData *,"");
- BBTK_INPUT(SegmentationConnectivity,PositionXYZ,"vector with the Position [x y z]" , std::vector<int>,"");
- BBTK_INPUT(SegmentationConnectivity,ThresholdMinMax,"vector with the Threshold [min max]" , std::vector<int>,"");
- BBTK_OUTPUT(SegmentationConnectivity,Out,"Result image",vtkImageData *,"");
- BBTK_END_DESCRIBE_BLACK_BOX(SegmentationConnectivity);
+ BBTK_NAME("SegmentationConnectivity");
+ BBTK_AUTHOR("eduardo.davila [at] creatis.insa-lyon.fr");
+ BBTK_DESCRIPTION("Segmentation with min max threshold and connectivity");
+
+ BBTK_INPUT(SegmentationConnectivity,In,"Input image",vtkImageData *,"");
+ BBTK_INPUT(SegmentationConnectivity,PositionXYZ,"vector with the Position [x y z]" , std::vector<int>,"");
+ BBTK_INPUT(SegmentationConnectivity,ThresholdMinMax,"vector with the Threshold [min max]" , std::vector<int>,"");
+ BBTK_INPUT(SegmentationConnectivity,Value,"(255 default) [0..255] Gey level of output image" , unsigned char,"");
+ BBTK_INPUT(SegmentationConnectivity,OutputFormat,"Image output format: SAME (default), VTK_BIT, VTK_CHAR, VTK_SIGNED_CHAR, VTK_UNSIGNED_CHAR, VTK_SHORT, VTK_UNSIGNED_SHORT, VTK_INT, VTK_UNSIGNED_INT, VTK_LONG, VTK_UNSIGNED_LONG, VTK_FLOAT, VTK_DOUBLE",std::string,"");
+
+ BBTK_OUTPUT(SegmentationConnectivity,Out,"Result image",vtkImageData *,"");
+
+ BBTK_END_DESCRIBE_BLACK_BOX(SegmentationConnectivity);
} // EO namespace bbvtk