src/eventListeners/internals/renderSegmentationOutline.js
/**
 * _getPixelIndiciesAroundPixel - Returnns the coordinates for up to 8 surrounding
 * pixels, if they within the bounds of the image.
 *
 * @param  {Object} coord The coordinate to check.
 * @param  {number} rows The number of rows in the image.
 * @param  {number} cols The number of cols in the image.
 *
 * @returns {Object} Object containing the position of adjacent pixels.
 */
Returnns the coordinates for up to 8 surrounding
pixels, if they within the bounds of the image.

@param  {Object} coord The coordinate to check.
@param  {number} rows The number of rows in the image.
@param  {number} cols The number of cols in the image.

@returns {Object} Object containing the position of adjacent pixels.
Returnns the coordinates for up to 8 surrounding pixels if they within the bounds of the image . @param { Object } coord The coordinate to check . @param { number } rows The number of rows in the image . @param { number } cols The number of cols in the image . @returns { Object } Object containing the position of adjacent pixels .
function _getPixelIndiciesAroundPixel(coord, rows, cols) {
  const pixelIndex = coord.y * cols + coord.x;
  const pixel = {};
  const hasPixelToTop = coord.y - 1 >= 0;
  const hasPixelToBotoom = coord.y + 1 < rows;
  const hasPixelToLeft = coord.x - 1 >= 0;
  const hasPixelToRight = coord.x + 1 < cols;
  if (hasPixelToTop) {
    pixel.top = pixelIndex - cols;
    if (hasPixelToRight) {
      pixel.topRight = pixel.top + 1;
    }
    if (hasPixelToLeft) {
      pixel.topLeft = pixel.top - 1;
    }
  }
  if (hasPixelToBotoom) {
    pixel.bottom = pixelIndex + cols;
    if (hasPixelToRight) {
      pixel.bottomRight = pixel.bottom + 1;
    }
    if (hasPixelToLeft) {
      pixel.bottomLeft = pixel.bottom - 1;
    }
  }
  if (hasPixelToLeft) {
    pixel.left = pixelIndex - 1;
  }
  if (hasPixelToRight) {
    pixel.right = pixelIndex + 1;
  }
  return pixel;
}
function _getPixelIndiciesAroundPixel ( coord , rows , cols ) { const pixelIndex = coord . y * cols + coord . x ; const pixel = { } ; const hasPixelToTop = coord . y - 1 >= 0 ; const hasPixelToBotoom = coord . y + 1 < rows ; const hasPixelToLeft = coord . x - 1 >= 0 ; const hasPixelToRight = coord . x + 1 < cols ; if ( hasPixelToTop ) { pixel . top = pixelIndex - cols ; if ( hasPixelToRight ) { pixel . topRight = pixel . top + 1 ; } if ( hasPixelToLeft ) { pixel . topLeft = pixel . top - 1 ; } } if ( hasPixelToBotoom ) { pixel . bottom = pixelIndex + cols ; if ( hasPixelToRight ) { pixel . bottomRight = pixel . bottom + 1 ; } if ( hasPixelToLeft ) { pixel . bottomLeft = pixel . bottom - 1 ; } } if ( hasPixelToLeft ) { pixel . left = pixelIndex - 1 ; } if ( hasPixelToRight ) { pixel . right = pixelIndex + 1 ; } return pixel ; }
_getPixelIndiciesAroundPixel - Returnns the coordinates for up to 8 surrounding
 pixels, if they within the bounds of the image.
_getPixelIndiciesAroundPixel - Returnns the coordinates for up to 8 surrounding pixels if they within the bounds of the image .