code: def cut_raw_images(all_images, path):
      """Preprocess images:
      (1) Crop the central square including retina
      (2) Reduce resolution to 512 * 512
      """
      print("Num of images to be processed: %d" % len(all_images))
      try:
          import cv2
      except:
          logger.warn("OpenCV required for image preprocessing")
          return
  
      for i, img_path in enumerate(all_images):
          if i % 100 == 0:
              print("on image %d" % i)
          if os.path.join(
              path, "cut_" + os.path.splitext(img_path)[0] + ".png"
          ):
              continue
          img = cv2.imread(os.path.join(path, img_path))
          edges = cv2.Canny(img, 10, 30)
          coords = zip(*np.where(edges > 0))
          n_p = len(coords)
  
          coords.sort(key=lambda x: (x[0], x[1]))
          center_0 = int(
              (coords[int(0.01 * n_p)][0] + coords[int(0.99 * n_p)][0])
              / 2
          )
          coords.sort(key=lambda x: (x[1], x[0]))
          center_1 = int(
              (coords[int(0.01 * n_p)][1] + coords[int(0.99 * n_p)][1])
              / 2
          )
  
          edge_size = min(
              [
                  center_0,
                  img.shape[0] - center_0,
                  center_1,
                  img.shape[1] - center_1,
              ]
          )
          img_cut = img[
              (center_0 - edge_size) : (center_0 + edge_size),
              (center_1 - edge_size) : (center_1 + edge_size),
          ]
          img_cut = cv2.resize(img_cut, (512, 512))
          cv2.imwrite(
              os.path.join(
                  path, "cut_" + os.path.splitext(img_path)[0] + ".png"
              ),
              img_cut,
          )
  
file_path: deepchem/contrib/DiabeticRetinopathy/data.py
imports: from __future__ import division
  from __future__ import unicode_literals
  import os
  import logging
  import deepchem
  import numpy
  import pandas
label_desc: Use image node_id 2 for calling a global function with example usage: cut_raw_images(all_images, path) without return types