def extract_contours
      contours = Array.new
      if @narray.segmented?
        # Get contours:
        corners, continuous  = extract_single_contour
        # If we dont get at least 3 indices, there is no area to fill.
        if continuous.indices.length < 3
          # In this case we remove the pixels and do not record the contour indices:
          roi = continuous
        else
          # Record the indices and get all indices of the structure:
          contours << corners
          # Flood fill the image to determine all pixels contained by the contoured structure:
          roi = roi_indices(continuous)
          # A precaution:
          raise "Unexpected result: #{roi.indices.length}. Raising an error to avoid an infinite recursion!" if roi.indices.length < 3
        end
        # Reset the pixels belonging to the contoured structure from the image:
        @narray[roi.indices] = 0
        # Repeat with the 'cleaned' image to get any additional contours present:
        contours += extract_contours
      end
      return contours
    end
def extract_contours
      contours = Array.new
      if @narray.segmented?
        # Get contours:
        corners, continuous  = extract_single_contour
        # If we dont get at least 3 indices, there is no area to fill.
        if continuous.indices.length < 3
          # In this case we remove the pixels and do not record the contour indices:
          roi = continuous
        else
          # Record the indices and get all indices of the structure:
          contours << corners
          # Flood fill the image to determine all pixels contained by the contoured structure:
          roi = roi_indices(continuous)
          # A precaution:
          raise "Unexpected result: #{roi.indices.length}. Raising an error to avoid an infinite recursion!" if roi.indices.length < 3
        end
        # Reset the pixels belonging to the contoured structure from the image:
        @narray[roi.indices] = 0
        # Repeat with the 'cleaned' image to get any additional contours present:
        contours += extract_contours
      end
      return contours
    end
This is a recursive method which extracts a contour, determines all pixels
 belonging to this contour, removes them from the binary image, then
 repeats collecting contours until there are no more pixels left.

 @return [Array<Selection>] an array of indices for all the contours derived from the segmented image