code: def test_slice_image(self):
      # read coco file
      coco_path = "tests/data/coco_utils/terrain1_coco.json"
      coco = Coco.from_coco_dict_or_path(coco_path)
  
      output_file_name = None
      output_dir = None
      image_path = "tests/data/coco_utils/" + coco.images[0].file_name
      slice_image_result = slice_image(
          image=image_path,
          coco_annotation_list=coco.images[0].annotations,
          output_file_name=output_file_name,
          output_dir=output_dir,
          slice_height=512,
          slice_width=512,
          overlap_height_ratio=0.1,
          overlap_width_ratio=0.4,
          min_area_ratio=0.1,
          out_ext=".png",
          verbose=False,
      )
  
      self.assertEqual(len(slice_image_result), 18)
      self.assertEqual(len(slice_image_result.images), 18)
      self.assertEqual(len(slice_image_result.coco_images), 18)
      self.assertEqual(
          slice_image_result.coco_images[0].annotations, []
      )
      self.assertEqual(
          slice_image_result.coco_images[15].annotations[1].area, 7296
      )
      self.assertEqual(
          slice_image_result.coco_images[15].annotations[1].bbox,
          [17, 186, 48, 152],
      )
      self.assertEqual(type(slice_image_result[0]), dict)
      self.assertEqual(
          slice_image_result[0]["image"].shape, (512, 512, 3)
      )
      self.assertEqual(
          slice_image_result[3]["starting_pixel"], [924, 0]
      )
      self.assertEqual(type(slice_image_result[0:4]), list)
      self.assertEqual(len(slice_image_result[0:4]), 4)
  
      image_cv = read_image(image_path)
      slice_image_result = slice_image(
          image=image_cv,
          coco_annotation_list=coco.images[0].annotations,
          output_file_name=output_file_name,
          output_dir=output_dir,
          slice_height=512,
          slice_width=512,
          overlap_height_ratio=0.1,
          overlap_width_ratio=0.4,
          min_area_ratio=0.1,
          out_ext=".png",
          verbose=False,
      )
  
      self.assertEqual(len(slice_image_result.images), 18)
      self.assertEqual(len(slice_image_result.coco_images), 18)
      self.assertEqual(
          slice_image_result.coco_images[0].annotations, []
      )
      self.assertEqual(
          slice_image_result.coco_images[15].annotations[1].area, 7296
      )
      self.assertEqual(
          slice_image_result.coco_images[15].annotations[1].bbox,
          [17, 186, 48, 152],
      )
  
      image_pil = Image.open(image_path)
      slice_image_result = slice_image(
          image=image_pil,
          coco_annotation_list=coco.images[0].annotations,
          output_file_name=output_file_name,
          output_dir=output_dir,
          slice_height=512,
          slice_width=512,
          overlap_height_ratio=0.1,
          overlap_width_ratio=0.4,
          min_area_ratio=0.1,
          out_ext=".png",
          verbose=False,
      )
  
      self.assertEqual(len(slice_image_result.images), 18)
      self.assertEqual(len(slice_image_result.coco_images), 18)
      self.assertEqual(
          slice_image_result.coco_images[0].annotations, []
      )
      self.assertEqual(
          slice_image_result.coco_images[15].annotations[1].area, 7296
      )
      self.assertEqual(
          slice_image_result.coco_images[15].annotations[1].bbox,
          [17, 186, 48, 152],
      )
  
file_path: sahi/tests/test_slicing.py
imports: import unittest
  import numpy
  from PIL import Image
  from sahi.slicing import shift_bboxes, shift_masks, slice_coco, slice_image
  from sahi.utils.coco import Coco
  from sahi.utils.cv import read_image
label_desc: Use image node_id 1 for calling the TestSlicing obj's underlying member method code with example usage: obj.test_slice_image() without return types