X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=itk%2FclitkSegmentationUtils.txx;h=00f3392f17a91477f3c4bc5790da0c97f05f95a0;hb=d8b45274cd67177427f3480f2ce4e9345d83612f;hp=3da1802b601169925717ace6c3c1528cc48a802b;hpb=acce45844cc7d465d97939f42a56d81a6cf80179;p=clitk.git diff --git a/itk/clitkSegmentationUtils.txx b/itk/clitkSegmentationUtils.txx index 3da1802..00f3392 100644 --- a/itk/clitkSegmentationUtils.txx +++ b/itk/clitkSegmentationUtils.txx @@ -388,7 +388,7 @@ namespace clitk { /* loop over input pixels, store the index in the fg that is max according to the given direction. - */ + */ typedef itk::ImageRegionConstIteratorWithIndex IteratorType; IteratorType iter(input, input->GetLargestPossibleRegion()); iter.GoToBegin(); @@ -535,27 +535,6 @@ namespace clitk { //-------------------------------------------------------------------- - //-------------------------------------------------------------------- - template - typename ImageType::Pointer - JoinSlices(std::vector::Pointer > & slices, - const ImageType * input, - int direction) { - typedef typename itk::Image SliceType; - typedef itk::JoinSeriesImageFilter JoinSeriesFilterType; - typename JoinSeriesFilterType::Pointer joinFilter = JoinSeriesFilterType::New(); - joinFilter->SetOrigin(input->GetOrigin()[direction]); - joinFilter->SetSpacing(input->GetSpacing()[direction]); - for(unsigned int i=0; iPushBackInput(slices[i]); - } - joinFilter->Update(); - return joinFilter->GetOutput(); - } - //-------------------------------------------------------------------- - - //-------------------------------------------------------------------- template void @@ -923,5 +902,60 @@ namespace clitk { //-------------------------------------------------------------------- + //-------------------------------------------------------------------- + /* Consider an input object, for each slice, find the extrema + position according to a given direction and build a line segment + passing throught this point in a given direction. Output is a + vector of line (from point A to B), for each slice; + */ + template + void + SliceBySliceBuildLineSegmentAccordingToExtremaPosition(const ImageType * input, + typename ImageType::PixelType BG, + int sliceDimension, + int extremaDirection, + bool extremaOppositeFlag, + int lineDirection, + double margin, + std::vector & A, + std::vector & B) + { + // Type of a slice + typedef typename itk::Image SliceType; + + // Build the list of slices + std::vector slices; + clitk::ExtractSlices(input, sliceDimension, slices); + + // Build the list of 2D points + std::map position2D; + for(uint i=0; i(slices[i], BG, + extremaDirection, extremaOppositeFlag, p); + if (found) { + position2D[i] = p; + } + } + + // Convert 2D points in slice into 3D points + clitk::PointsUtils::Convert2DTo3DList(position2D, input, A); + + // Create additional point just right to the previous ones, on the + // given lineDirection, in order to create a horizontal/vertical line. + for(uint i=0; i