MCPcopy Create free account
hub / github.com/Kitware/VTK / GetNeighbors

Method GetNeighbors

Filters/Hybrid/vtkImageToPolyDataFilter.cxx:623–670  ·  view source on GitHub ↗

Get the left-right-top-bottom neighboring pixels of a given pixel The method has been modified to return right neighbor (mode==0); or top neighbor (mode==1) or all neighbors (mode==2).

Source from the content-addressed store, hash-verified

621// The method has been modified to return right neighbor (mode==0);
622// or top neighbor (mode==1) or all neighbors (mode==2).
623int vtkImageToPolyDataFilter::GetNeighbors(
624 unsigned char* ptr, int& i, int& j, int dims[2], unsigned char* neighbors[4], int mode)
625{
626 int numNeis = 0;
627
628 if (mode == 0)
629 {
630 if ((i + 1) < dims[0])
631 {
632 neighbors[numNeis++] = ptr + 3; // jump over rgb
633 }
634 if ((i - 1) >= 0)
635 {
636 neighbors[numNeis++] = ptr - 3; // jump over rgb
637 }
638 }
639
640 else if (mode == 1)
641 {
642 if ((j + 1) < dims[1])
643 {
644 neighbors[numNeis++] = ptr + 3 * dims[0];
645 }
646 }
647
648 else
649 {
650 if ((i + 1) < dims[0])
651 {
652 neighbors[numNeis++] = ptr + 3; // jump over rgb
653 }
654 if ((i - 1) >= 0)
655 {
656 neighbors[numNeis++] = ptr - 3;
657 }
658
659 if ((j + 1) < dims[1])
660 {
661 neighbors[numNeis++] = ptr + 3 * dims[0];
662 }
663 if ((j - 1) >= 0)
664 {
665 neighbors[numNeis++] = ptr - 3 * dims[0];
666 }
667 }
668
669 return numNeis;
670}
671
672// Marks connected regions with different colors.
673int vtkImageToPolyDataFilter::ProcessImage(vtkUnsignedCharArray* scalars, int dims[2])

Callers 1

ProcessImageMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected