
# draw all contours in green and accepted ones in redĬontours = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)Ĭontours = contours if len(contours) = 2 else contoursĬv2.drawContours(result,, -1, (0, 255, 0), 1)Ĭv2. # find contours and get one with area about 180*35 Thresh = cv2.threshold(gray, 30, 255, cv2.THRESH_BINARY) Gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

Here is one way to do that in Python/OpenCV.

Help is appreciated, since I'm kind of unexperienced with OpenCV. Browse Getty Images premium collection of high-quality, authentic White Rectangle Box stock photos, royalty-free images and pictures. If this should be the wrong way of doing it, please correct me. White Ceramic Rectangular Planter Box Indoor (4.2k) 25.56 28.40 (10 off) Vtg Ceramic Planter/Vase/Pot/Centerpiece White Faux Wicker Pottery Rectangle Large & Heavy 9x11 Vintage (637) 130.00 Rectangular Ceramic Succulent Planter Pot 6.5' White Shallow Ceramic Bowl with Drainage Hole and Bamboo Saucer (1.3k) 16. I tried it with cv2.findContours(image, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE) and a few other functions, but I was not successful yet. Now I want to crop the image to the big box in the middle only, but I'm not able to detect the contours of it. With this being done the program outputs this: #invert colors, so every dark spots are now white Ret, thresh = cv2.threshold(s, 8, 255, cv2.THRESH_BINARY)

#get the saturation plane - all black/white/gray pixels are zero, and colored pixels are above zero. Hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV) Img = cv2.imread('rdm_generated_image.png') So far I was able to input it, convert its colors to a HSV color space and applying threshold on it. I'm struggling with cropping an image to the size of a rectangle, which is placed inside of the image.
