class_docstr: Decoding predictions of TextSnake to instances. This was partially
  adapted from https://github.com/princewang1994/TextSnake.pytorch.
  
  Args:
      text_repr_type (str): The boundary encoding type 'poly' or 'quad'.
      min_text_region_confidence (float): The confidence threshold of text
          region in TextSnake.
      min_center_region_confidence (float): The confidence threshold of text
          center region in TextSnake.
      min_center_area (int): The minimal text center region area.
      disk_overlap_thr (float): The radius overlap threshold for merging
          disks.
      radius_shrink_ratio (float): The shrink ratio of ordered disks radii.
      rescale_fields (list[str], optional): The bbox/polygon field names to
          be rescaled. If None, no rescaling will be performed.
class_docstr_tok: ["Decoding","predictions","of","TextSnake","to","instances",".","This","was","partially","adapted","from","https",":","\/\/github.com\/princewang1994\/TextSnake.pytorch",".","Args",":","text_repr_type","(","str",")",":","The","boundary","encoding","type","'poly","'","or","'quad","'",".","min_text_region_confidence","(","float",")",":","The","confidence","threshold","of","text","region","in","TextSnake",".","min_center_region_confidence","(","float",")",":","The","confidence","threshold","of","text","center","region","in","TextSnake",".","min_center_area","(","int",")",":","The","minimal","text","center","region","area",".","disk_overlap_thr","(","float",")",":","The","radius","overlap","threshold","for","merging","disks",".","radius_shrink_ratio","(","float",")",":","The","shrink","ratio","of","ordered","disks","radii",".","rescale_fields","(","list","[","str","]",",","optional",")",":","The","bbox\/polygon","field","names","to","be","rescaled",".","If","None",",","no","rescaling","will","be","performed","."]
docstr: Centralize the points.
  
  Args:
      points_yx (np.array): The points in yx order.
      normal_cos (torch.Tensor): The normal cosine of the points.
      normal_sin (torch.Tensor): The normal sine of the points.
      radius (torch.Tensor): The radius of the points.
      contour_mask (np.array): The contour mask of the points.
      step_ratio (float): The step ratio of the centralization.
          Defaults to 0.03.
  
  Returns:
      np.ndarray: The centralized points.
docstr_tok: ["Centralize","the","points",".","Args",":","points_yx","(","np.array",")",":","The","points","in","yx","order",".","normal_cos","(","torch.Tensor",")",":","The","normal","cosine","of","the","points",".","normal_sin","(","torch.Tensor",")",":","The","normal","sine","of","the","points",".","radius","(","torch.Tensor",")",":","The","radius","of","the","points",".","contour_mask","(","np.array",")",":","The","contour","mask","of","the","points",".","step_ratio","(","float",")",":","The","step","ratio","of","the","centralization",".","Defaults","to","0.03",".","Returns",":","np.ndarray",":","The","centralized","points","."]
code: def _centralize(
      points_yx: np.ndarray,
      normal_cos: torch.Tensor,
      normal_sin: torch.Tensor,
      radius: torch.Tensor,
      contour_mask: np.ndarray,
      step_ratio: float = 0.03,
  ) -> np.ndarray:
      """Centralize the points.
  
      Args:
          points_yx (np.array): The points in yx order.
          normal_cos (torch.Tensor): The normal cosine of the points.
          normal_sin (torch.Tensor): The normal sine of the points.
          radius (torch.Tensor): The radius of the points.
          contour_mask (np.array): The contour mask of the points.
          step_ratio (float): The step ratio of the centralization.
              Defaults to 0.03.
  
      Returns:
          np.ndarray: The centralized points.
      """
  
      h, w = contour_mask.shape
      top_yx = bot_yx = points_yx
      step_flags = np.ones((len(points_yx), 1), dtype=np.bool_)
      step = step_ratio * radius * np.hstack([normal_cos, normal_sin])
      while np.any(step_flags):
          next_yx = np.array(top_yx + step, dtype=np.int32)
          next_y, next_x = next_yx[:, 0], next_yx[:, 1]
          step_flags = (
              (next_y >= 0)
              & (next_y < h)
              & (next_x > 0)
              & (next_x < w)
              & contour_mask[
                  np.clip(next_y, 0, h - 1), np.clip(next_x, 0, w - 1)
              ]
          )
          top_yx = top_yx + step_flags.reshape((-1, 1)) * step
      step_flags = np.ones((len(points_yx), 1), dtype=np.bool_)
      while np.any(step_flags):
          next_yx = np.array(bot_yx - step, dtype=np.int32)
          next_y, next_x = next_yx[:, 0], next_yx[:, 1]
          step_flags = (
              (next_y >= 0)
              & (next_y < h)
              & (next_x > 0)
              & (next_x < w)
              & contour_mask[
                  np.clip(next_y, 0, h - 1), np.clip(next_x, 0, w - 1)
              ]
          )
          bot_yx = bot_yx - step_flags.reshape((-1, 1)) * step
      centers = np.array((top_yx + bot_yx) * 0.5, dtype=np.int32)
      return centers
  
file_path: mmocr/mmocr/models/textdet/postprocessors/textsnake_postprocessor.py
imports: from typing import List, Sequence
  import cv2
  import numpy
  import torch
  from mmengine.structures import InstanceData
  from numpy.linalg import norm
  from skimage.morphology import skeletonize
  from mmocr.registry import MODELS
  from mmocr.structures import TextDetDataSample
  from mmocr.utils import fill_hole
  from .base import BaseTextDetPostProcessor
label_desc: Use image node_id 4 for calling the TextSnakePostprocessor obj's underlying member method code with example usage: obj._centralize(points_yx, normal_cos, normal_sin, radius, contour_mask, step_ratio) and returns: centers