4
$\begingroup$

I am trying to vectorize the contours (skewed rectangle) of the TV in the following original image.

oroginal

My first step is applying threshold. Tried selection of threshold values based on what skimage has to offer, but non of them managed (for example) to separate correctly the little fawn to the left, or the TV stand from the TV border. For example this is the result using yen's method:

bw

Can you suggest any preprocessing that may help before applying a threshold ?

$\endgroup$
1
$\begingroup$

In your case, I don't think a pre-processing is necessary. You may find the Hough transform useful in your case.

Since your image is big, it can be difficult to have a straight line due to the noise and blur.

This is what I got using a sobel contour detection with a smaller version of your image.

This is maybe a good start to use a line detection algorithm.

Input image after resizing and sobel contour detection

A second solution would be to use color segmentation. If you assume that your screen would always have black border you can work something in the LAb or HSV color space.

$\endgroup$
0
$\begingroup$

I think the result you've already shown is about as good as you're going to get. What you need isn't preprocessing of the input image, but to give your edge detector a good idea of what contour it's looking for. If you write your contour extractor to look specifically for quadrilaterals, it'll easily be able to filter where the fawn sticks out at the bottom left, and the stand at the bottom. Then it's just a question of finding the one that corresponds to the TV (probably the largest, but it depends on what other images you're running it on).

$\endgroup$
  • $\begingroup$ can you reference an implementation of a contour detector for which you can specify shape? I was using find_contours (scikit-image.org/docs/dev/api/…) which apparently does no support that $\endgroup$ – dux2 Jun 23 '17 at 14:48
  • $\begingroup$ I can't think of an existing one; when I wrote the answer I was thinking you'd have to do it yourself. For an arbitrary shape that might be a lot of work but you're only looking for four lines. $\endgroup$ – Dan Hulme Jun 23 '17 at 18:43
  • $\begingroup$ actually after using find_contours I am indeed looking for rectangle myself, but I thought that if I can make find_contours produce better contours, my final result will be more accurate and less prone to lighting conditions. $\endgroup$ – dux2 Jun 24 '17 at 6:24

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.