-3

I was trying the detect and extract an image from the background (Example image here). Used canny edge detection and Hough transform for lines detection. But I'm getting wrong result due to noise in the image. An example image (Intermediate result) is shown here. Kindly help me to solve this problem in python.

I have used technique from below site and in addition to this used idea of Hough transform.

https://www.pyimagesearch.com/2014/04/21/building-pokedex-python-finding-game-boy-screen-step-4-6/

  • Do you always detect that object? If not, please provide more example images. For the given example, color thresholding the purple body of the object using the HSV color space might be a promising approach. – HansHirse Feb 15 '21 at 12:23
  • As usual, trying to solve with edge detection, which rarely works, when image segmentation would be so obvious ! –  Feb 15 '21 at 12:52

1 Answers1

0

I hope this helps you:

import cv2

img = cv2.imread('image.jpg')
gray = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)[:, :, 2]
kern_size = 11
gray_blurred = cv2.medianBlur(gray, kern_size)
threshold_lower = 30
threshold_upper = 220
edged = cv2.Canny(gray_blurred, threshold_lower, threshold_upper)
cv2.imshow('edged',edged)
cv2.waitKey(0)

Your input image Edged and deteted object

Puya Fazlali
  • 436
  • 4
  • 9