[vtkusers] vtkEdgeFollower?
Sven Prevrhal
Sven.Prevrhal at oarg.ucsf.edu
Thu Sep 28 11:56:16 EDT 2000
Thanks,
I have successfully used your code! I also found out about edgels (from the Tcl example
Canny.tcl), and after linking and filtering the edgels to extract the contour of interest, I
connect them with vtkPolyDataConnectivity. It works, except one problem: If there's even a tiny
hole in the contour, then the connectivity filter cannot jump over it. Is there a remedy for that?
sven
Here's my code (more or less Canny.tcl except the vtkPolyDataConnectivity at the end):
vtkImageCast ic
ic SetOutputScalarTypeToFloat
ic SetInput $img; # img is vtkImageData
# smooth the image
vtkImageGaussianSmooth gs
gs SetInput [ic GetOutput]
gs SetDimensionality 2
gs SetRadiusFactors 1 1 0
# gradient the image
vtkImageGradient imgGradient;
imgGradient SetInput [gs GetOutput];
imgGradient SetDimensionality 2
vtkImageMagnitude imgMagnitude
imgMagnitude SetInput [imgGradient GetOutput]
# non maximum suppression
vtkImageNonMaximumSuppression nonMax;
nonMax SetVectorInput [imgGradient GetOutput];
nonMax SetMagnitudeInput [imgMagnitude GetOutput];
nonMax SetDimensionality 2
vtkImageConstantPad pad
pad SetInput [imgGradient GetOutput]
pad SetOutputNumberOfScalarComponents 3
pad SetConstant 0
vtkImageToStructuredPoints i2sp1
i2sp1 SetInput [nonMax GetOutput]
i2sp1 SetVectorInput [pad GetOutput]
# link edgles
vtkLinkEdgels imgLink;
imgLink SetInput [i2sp1 GetOutput];
imgLink SetGradientThreshold 2;
imgLink SetPhiThreshold 45
imgLink SetLinkThreshold 80
# threshold links
vtkThreshold thresholdEdgels;
thresholdEdgels SetInput [imgLink GetOutput];
thresholdEdgels ThresholdBetween 40 60;
thresholdEdgels AllScalarsOff
vtkGeometryFilter gf
gf SetInput [thresholdEdgels GetOutput]
vtkImageToStructuredPoints i2sp
i2sp SetInput [imgMagnitude GetOutput]
i2sp SetVectorInput [pad GetOutput]
# subpixel them
#vtkSubPixelPositionEdgels spe;
#spe SetInput [gf GetOutput];
#spe SetGradMaps [i2sp GetOutput];
vtkPolyDataConnectivityFilter connect
connect SetExtractionModeToLargestRegion
connect SetInput [gf GetOutput]
m.petrone at cineca.it wrote:
> Sven Prevrhal wrote:
>
> > Hello,
> > I'd like to have a threshold-based edge follower with a seed point. Is
> > there something similar available? If not, how would I write it?
> > I guess derived from vtkImageToPolyDataFilter since the output would be
> > ..hmmm.. vtkPoints, as part of poly data?
>
> Some times ago I did something similar with this pipeline:
>
> vtkImageThreshold thresh
> thresh ThresholdByUpper $myvars(thresh)
> thresh ReplaceInOn
> thresh ReplaceOutOn
> thresh SetOutValue 0
> thresh SetInValue 255
> thresh SetInput [clipper GetOutput]
>
> vtkMarchingSquares contour
> contour SetInput [thresh GetOutput]
> contour SetNumberOfContours 1
> contour SetValue 1 255
>
> vtkPolyDataConnectivityFilter connect
> connect SetExtractionModeToLargestRegion
> connect SetInput [contour GetOutput]
>
> vtkCleanPolyData cleaner
> cleaner SetInput [connect GetOutput]
>
> Where clipper was a vtkClipImage applied to the input image. I used this to extract contours
> of "flints". In that case flints were putted over a dark background, which allowed to have a
> good precision in reproducing contours from the initial image. The obtained polydata was
> composed of one or more cells of lines, from which I tried to extract invariant moments of the
> figure.
>
> Marco.
More information about the vtkusers
mailing list