itkGetConstMacro(FillHolesFlag, bool);
itkBooleanMacro(FillHolesFlag);
+ // Step Auto Crop
+ itkSetMacro(AutoCrop, bool);
+ itkGetConstMacro(AutoCrop, bool);
+ itkBooleanMacro(AutoCrop);
+
protected:
ExtractLungFilter();
virtual ~ExtractLungFilter() {}
MaskImagePixelType m_BackgroundValue;
MaskImagePixelType m_ForegroundValue;
int m_MinimalComponentSize;
+ bool m_AutoCrop;
// Step 1
InputImagePixelType m_UpperThreshold;
// Step 6
FillHolesFlagOn();
+ AutoCropOn();
}
//--------------------------------------------------------------------
//--------------------------------------------------------------------
PrintMemory(GetVerboseMemoryFlag(), "before autocropfilter");
if (m_Seeds.size() != 0) { // if ==0 ->no trachea found
- trachea = clitk::AutoCrop<MaskImageType>(trachea, GetBackgroundValue());
+ if (GetAutoCrop())
+ trachea = clitk::AutoCrop<MaskImageType>(trachea, GetBackgroundValue());
StopCurrentStep<MaskImageType>(trachea);
PrintMemory(GetVerboseMemoryFlag(), "after delete trachea");
}
//--------------------------------------------------------------------
StartNewStep("Cropping lung");
PrintMemory(GetVerboseMemoryFlag(), "Before Autocropfilter");
- working_mask = clitk::AutoCrop<MaskImageType>(working_mask, GetBackgroundValue());
+ if (GetAutoCrop())
+ working_mask = clitk::AutoCrop<MaskImageType>(working_mask, GetBackgroundValue());
StopCurrentStep<MaskImageType>(working_mask);
//--------------------------------------------------------------------
//--------------------------------------------------------------------
template <class ImageType>
-void
+void
clitk::ExtractLungFilter<ImageType>::
SearchForTrachea()
{
double volume = 0.0;
int skip = GetNumberOfSlicesToSkipBeforeSearchingSeed();
while (!stop) {
- stop = SearchForTracheaSeed(skip);
- if (stop) {
+ stop = true;
+ if (SearchForTracheaSeed(skip)) {
TracheaRegionGrowing();
volume = ComputeTracheaVolume()/1000; // assume mm3, so divide by 1000 to get cc
if (GetWriteStepFlag()) {
if (GetVerboseStepFlag()) {
std::cout << "\t Found trachea with volume " << volume << " cc." << std::endl;
}
- stop = true;
}
else {
if (GetVerboseStepFlag()) {
// empty the list of seed
m_Seeds.clear();
}
+ if (skip > 0.5 * working_input->GetLargestPossibleRegion().GetSize()[2]) {
+ // we want to skip more than a half of the image, it is probably a bug
+ std::cerr << "2 : Number of slices to skip to find trachea too high = " << skip << std::endl;
+ stop = true;
+ }
}
else {
stop = true;