Ask Your Question

Drakem's profile - activity

2020-08-30 11:40:47 -0500 received badge  Nice Question (source)
2016-09-12 04:46:03 -0500 received badge  Famous Question (source)
2016-09-12 04:46:03 -0500 received badge  Popular Question (source)
2016-09-12 04:46:03 -0500 received badge  Notable Question (source)
2016-02-14 10:51:42 -0500 commented question Detach blobs with a contact point

Here's the code for the axes and the curve:

// Drawing orientation angle
float angle = -rod.orientation;
float length = rod.length/5;
ellipse(image, rod.barycenter, Size(rod.length/6,rod.length/6), 0, 0, -rod.orientation, Scalar(0,0,255));
Point2f P2;
P2.x =  (rod.barycenter.x + length * cos(angle * CV_PI / 180.0));
P2.y =  (rod.barycenter.y + length * sin(angle * CV_PI / 180.0));
arrowedLine(image, rod.barycenter, P2, Scalar(255,255,255));
P2.x =  (rod.barycenter.x + length * cos(0));
P2.y =  (rod.barycenter.y + length * sin(0));
arrowedLine(image, rod.barycenter, P2, Scalar(0,0,255));

Basically i draw 2 arrowed lines of certain length stasrting from barycenter, then i properly draw a portion of ellipse (circle) to draw the angle.

2016-02-14 08:52:22 -0500 commented answer Detach blobs with a contact point

I implemented a very naive selection, iterating on every couple of defect points (excluding the couple (x,x) of course) and thresholding the L2 distance between the points of the couple. I tuned the threshold until in worked, but i know this is not a very robust implementation. I could improve it connecting one defect point to the nearest one, as Tetragramm suggested below. Anyway, i added the code to the original post.

2016-02-14 08:33:48 -0500 received badge  Student (source)
2016-02-14 08:29:02 -0500 received badge  Editor (source)
2016-02-14 08:25:58 -0500 commented answer Detach blobs with a contact point

Thank you very very much, that worked like a charm! I adapted your code to draw a line through the defect points and wrote an algorithm to fix some imperfections (in the second image case, the line go through the little blob head, resulting into opening the hole, so my algorithm does a sort of reconstruction of the image border). I edited the original post with the results.

2016-02-14 05:54:31 -0500 received badge  Scholar (source)
2016-02-14 05:54:29 -0500 received badge  Supporter (source)
2016-02-13 10:53:24 -0500 asked a question Detach blobs with a contact point

Hello. I'm working with blob analysis and i'm having problems on detaching 2 blobs which have a contact point. The images i'm working on are of this type:

image description image description

These are the same images binarized:

image description image description

My problem is morphological operators like erosion, dilation and opening don't work since the dimensions of the contact points are the same or even greater than some important points of the image (like the heads of the objects with 2 holes) and so when I set my operator (opening in this case) in order to delete contact points I end up deleting also parts of the image which I need to do other calculations (like number of holes per object).

I thought of applying a certain number of opening operators using a rectangle oriented as each of the objects as structuring element (as suggested here, but this solution doesn't work well, since it is not assured that the contact points are oriented as one of the objects involved (as it happens, for example, for the contact point in the inferior part of the second image). Anyone of you have ideas of how I could solve this problem?

Edit: Here are the results thanks to sturkmen

image description image description

image description image description

2016-02-08 12:52:14 -0500 commented question Exception while drawing oriented MBB with minAreaRect

Well, i'm very ashamed to say my mistake was as stupid as that... Sorry, i was doing a lot of editing on the code and i lost the line of developing.

2016-02-08 12:43:41 -0500 asked a question Exception while drawing oriented MBB with minAreaRect

As stated in the title, i'm trying to draw the oriented minimum bounding box of a blob through the use of findContours() and minAreaRect(). The problem is the following exception is thrown at runtime:

OpenCV Error: Assertion failed (points.checkVector(2) >= 0 && (points.depth() == CV_32F || points.depth() == CV_32S)) in cv::minAreaRect, file C:\buildslave64\win64_amdocl\2_4_PackSlave-win32-vc11-shared\opencv\modules\imgproc\src\contours.cpp, line 1913

My code is as follows:

// Drawing oriented MBB
    vector<vector<Point> > contours;
    vector<Vec4i> hierarchy;
    findContours(blobs , contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, Point(0,0));
    RotatedRect minRect = minAreaRect(blobs);
    Point2f vertices[4]; 
    for (int v = 0; v < 4; v++)
        line(blobs[b], vertices[v], vertices[(v+1)%4], Scalar(130));

The exception is thrown by the minAreaRect() function. The image on which i'm working is well initialized, since I saved it to file just before the code above, getting this result:

image description

Anyone has an idea of what the problem could be?

Ps: I'm using openCV 2.4.11 on Visual Studio 2012, Windows 10 machine