From: dsarrut Date: Mon, 28 Mar 2011 14:52:58 +0000 (+0000) Subject: add SliceBySliceBuildLineSegmentAccordingToExtremaPosition X-Git-Tag: v1.2.0~95 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=68aea2bc9484f5fba9fed243273509a8c3efc0ff;p=clitk.git add SliceBySliceBuildLineSegmentAccordingToExtremaPosition --- diff --git a/itk/clitkSegmentationUtils.h b/itk/clitkSegmentationUtils.h index 468f9d8..6eecad0 100644 --- a/itk/clitkSegmentationUtils.h +++ b/itk/clitkSegmentationUtils.h @@ -362,6 +362,22 @@ namespace clitk { IsOnTheSameLineSide(PointType C, PointType A, PointType B, PointType like); //-------------------------------------------------------------------- + + //-------------------------------------------------------------------- + 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); + //-------------------------------------------------------------------- + + } #include "clitkSegmentationUtils.txx" diff --git a/itk/clitkSegmentationUtils.txx b/itk/clitkSegmentationUtils.txx index 2b5f685..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(); @@ -902,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