# add border/padding around the cropped image Img = cv2.cvtColor(numpy.array(img), cv2.COLOR_RGB2BGR) Img = ImageCms.profileToProfile(img, "USWebCoatedSWOP.icc", "sRGB_Color_Space_Profile.icm", outputMode="RGB") # color profiles can be found at C:\Program Files (x86)\Common Files\Adobe\Color\Profiles\Recommended # force opening truncated/corrupt image files So I needed a way to convert CMYK images to RGB, and then open it with OpenCV. And it seems OpenCV doesn't support CMYK. When I crop them, I get incorrect (vivid colors) output. Morphed = cv2.morphologyEx(threshed, cv2.MORPH_CLOSE, kernel)Ĭnts = cv2.findContours(morphed, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)Ĭnt = sorted(cnts, key=cv2.contourArea) Change photo background color and make background transparent easily. Remove background in bulk online for pictures of various categories with our free background eraser: people, vegetation, animals, sky, objects, cars, vehicles, graphics, icons, symbols. Kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (11,11)) Remove background from images automatically for free. Th, threshed = cv2.threshold(gray, 240, 255, cv2.THRESH_BINARY_INV) Gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) Then my steps to crop the target regions: I would like to completely get rid of the border as in be left with a rectangular box with either a white or a transparent background, having the length and width of the shoes in the picture. You requirement in the comment: The shoes are on a white background.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |