3

I have images of a smelting cube, forming into a droplet over time. So far, i extracted the contour of it, but next i'd need to to distinguish between object and surface. My Idea is to detect the corners where object touches surface, but i am struggling to find a reasonable approach how to do so (preferably using the c++ interface of opencv). I'd appreciate any suggestions.
Here are some examples of the extracted contour:
1 2 3 4

edit: @Haris:

i have tried a variant of your suggestion and it is doing the job for me:

r1 r2 r2

In the approximated contour i approach from the left, looking for the first angle with a value in a specified range, then the same from the right. As the approximated contour points are a subset of the original contour points, I then identify the 2 corner points in the original sequence, and cut it at both corners. The middle part i take as the droplet, and the left and right part, i reassamble to be my surface line. There might be better, more stable approaches, but this works for me. Thanks!

user2950911
  • 873
  • 3
  • 12
  • 19
  • Maybe it will be easier to distinguish the object from the surface with the original image (with a threshold for exemple). Is it possible for us to see the original image? – Irisciences Apr 04 '14 at 15:08
  • A first thought. If the points of contour are stored in order (as they are in image). I will pick a "good" d_Index said ~5 (for smooth small noise) and compute "tangent" vectors P[i+5]-P[i] for each point i. The inner products of adjoin tangent vectors will show a drop in corners. Find the min position/i (by linear interpolation ??) of the drop. The first min i_h and the last min i_e will segment the contour of the object from all. If you need the area, draw a line in the original image from P[i_h] to P[i_e] and find contour again. – maythe4thbewithu Apr 04 '14 at 16:28

1 Answers1

9

You can try this approach,

  1. Find contour and approxPolyDP.

  2. Suppose you got approxPolyDP point like P1,P2,P3 etc...

  3. Now calculate angle between consecutive line, that is angle between line(P1,P2), line(P2,P3) etc.. and check the difference in angle for each adjustment line, if the difference comes close to 90 degree you can say there is a corner.

For Angle you can use the equation

double Angle = atan2(y2 - y1, x2 - x1) * 180.0 / CV_PI; 
Haris
  • 13,645
  • 12
  • 90
  • 121
  • Thankyou for your answer! It certainly sounds good, I am unaware though which contour points exactly the approxPolyDP function will optimize out, and I am too tired right now to read myself into it, but will definitely get to it in the next few days :-) I'll let you know the outcome – user2950911 Apr 04 '14 at 22:30
  • 1
    approxPolyDP takes a precision or tolerance parameter that is important for angle calculation. It is easier to find a line in a tie sequence of frames since it stays the same while cube is melting. Something like foreground subtraction. – Vlad Apr 05 '14 at 05:40