// ------------------------------------------------------------------------ void computeProbImage(const PatchParams ¶ms, unsigned int pnum, unsigned int id, std::string type, ClassifierMap &classifiers, const ValveType::Pointer &valve, const LabelType::Pointer &mask, RealImageType::Pointer &output) { output = RealImageType::New(); output->SetDirection(mask->GetDirection()); output->SetSpacing(mask->GetSpacing()); output->SetOrigin(mask->GetOrigin()); output->SetRegions(mask->GetLargestPossibleRegion()); output->Allocate(); output->FillBuffer(0); itk::ImageRegionIterator<LabelType> maskIt(mask, mask->GetLargestPossibleRegion()); itk::ImageRegionIterator<RealImageType> probIt(output, output->GetLargestPossibleRegion()); unsigned int count = 0; while(!maskIt.IsAtEnd()) { if(maskIt.Get() == 255) { IndexType index = maskIt.GetIndex(); PointType point; output->TransformIndexToPhysicalPoint(index, point); MatrixType feature; extractLBPFeature(params, valve, point, feature); MatrixType probs; IntMatrixType classes; classifiers["MV-"+type][pnum]->PredictProbability(feature, classes, probs); probIt.Set(probs(0,1)); count++; } ++maskIt; ++probIt; } }
// ------------------------------------------------------------------------ void FlipImage(const LabelType::Pointer &input, LabelType::Pointer &output) { if(!output) output = LabelType::New(); ImageType::DirectionType outputDirection = input->GetDirection(); typedef itk::PermuteAxesImageFilter<LabelType> FlipperType; FlipperType::PermuteOrderArrayType axes; axes[0] = 1; axes[1] = 0; axes[2] = 2; FlipperType::Pointer flipper = FlipperType::New(); flipper->SetInput(input); flipper->SetOrder(axes); flipper->Update(); output = flipper->GetOutput(); output->SetDirection(outputDirection); }