def compute_n(ic)

      temp_ic = ImageCoordinate.cloneCoord(ic)

      n = -1  # compensate for 0,0 case

      x_off = [-1,0,1]
      y_off = [-1,0,1]

      x_off.each do |x|
        y_off.each do |y|

          temp_ic[:x] = ic[:x] + x
          temp_ic[:y] = ic[:y] + y

          if @im.inBounds(temp_ic) and @im[temp_ic] == @im[ic] then
            n += 1
          end

        end

      end

      temp_ic.recycle

      n

    end
def compute_n(ic)

      temp_ic = ImageCoordinate.cloneCoord(ic)

      n = -1  # compensate for 0,0 case

      x_off = [-1,0,1]
      y_off = [-1,0,1]

      x_off.each do |x|
        y_off.each do |y|

          temp_ic[:x] = ic[:x] + x
          temp_ic[:y] = ic[:y] + y

          if @im.inBounds(temp_ic) and @im[temp_ic] == @im[ic] then
            n += 1
          end

        end

      end

      temp_ic.recycle

      n

    end
implementation of skeletonization algorithm presented in Gonzalez & Woods, p 651-652