Given this image:

enter image description here

How can I extract the 'rectangle' my arm is holding up? I know about closing, dilation and erosion etc but I still manage to get artefacts of my hand included after filtering.

The size of that rectangle can vary due to varying distance if the camera.

I am using emgucv:

CvInvoke.Threshold(MyImage, MyImage, 10d, 255, ThresholdType.Binary);
var element = CvInvoke.GetStructuringElement( ElementShape.Cross, new Size( 3, 3 ), new Point( -1, -1 ) );     
CvInvoke.Erode( Threshold, Threshold, element, new Point( -1, -1 ), 1, BorderType.Reflect, default(MCvScalar) );

... and I would like image to 'roughly' look like this:

enter image description here

Any ideas?

  • 1
    $\begingroup$ Can you define which rectangle you actually would like to get? (because I honestly don't know which) $\endgroup$ – Marcus Müller Feb 12 '19 at 12:55
  • $\begingroup$ @m +1 for helping me to improve my question $\endgroup$ – Andrew Simpson Feb 12 '19 at 13:29
  • $\begingroup$ ah nice; hm, in that case, maybe try finding corners, e.g. through Hough transforms on the edges? $\endgroup$ – Marcus Müller Feb 12 '19 at 13:33
  • $\begingroup$ yes, that was where my mind was going to. I could iterate through each point of contours and then see the pattern of alignment and of width. I was concerned I was taking the long way round (my biggest bad habit) so, wanted to see if there was a better way through morphological functions. I will post back if I solve for other people. Off to gym :) $\endgroup$ – Andrew Simpson Feb 12 '19 at 13:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.