title: How can i read input only a part of the image without creating another image?
body: <pre><code>import cv2
  
  fname = '1.png'
  img=cv2.imread(fname, 0)
  print (img)//the outcome is an array of values from 0 to 255 (grayscale)
  ret, thresh = cv2.threshold(img, 254, 255, cv2.THRESH_BINARY)
  thresh = cv2.bitwise_not(thresh)
  nums, labels = cv2.connectedComponents(thresh, None, 4, cv2.CV_32S)
  dst = cv2.convertScaleAbs(255.0*labels/nums)
  cv2.imwrite(dest_dir+"output.png", dst)
  </code></pre>
  
  <p>that code works just fine, so i moved on to adjusting my code so it can take a portion of the image not the entire image:</p>
  
  <pre><code>from PIL import Image
  
      img = Image.open(fname)
      img2 = img.crop((int(xmin), int(yMin),int(xMax), int(yMax))
  </code></pre>
  
  <p>xmin ymin xmax ymax simply being the top left bottom right coordinates of the box.
  then i did <code>img = cv2.imread(img2)</code> to continue as the previous code but got an error, i printed img2 and got <code>&lt;PIL.Image.Image image mode=RGB size=54x10 at 0x7F4D283AFB70&gt;</code> how can i adjust it to be able to input that crop or image portion instead of fname in my code above, and kindly note i don't want to save img2 as an image and carry on from there because i need to work on the main image.</p>