Averaging shapes (boundary points) of arbitrary objects - image

I have few images (contours) of an object. However, I would like to average these shapes and use the averaged shape of the object for further shape analysis.
Example:
In the above image, I have stacked the contour to illustrate my example.
I have implemented the first two steps of the algorithm below:
1) Find centroid of both these object shape
2) Align the centers
3) Interpolate the object shape
Since, I am not representing the shapes using some parametric/analytic equation, how can I get the interpolated object shape (i.e. third step)?
Thanks in advance

If you do not have a parametric form for your shape, you can:
For each shape, create a signed distance field that is positive inside the boundary and negative outside (or vice-versa). This can be based on (e.g.) a distance transform and is evaluated at every pixel.
Compute the average of the signed distance fields
Compute the interpolated shape from the zero-crossing of the averaged field
I think this paper describes a similar method (though probably more sophisticated): "Shape-based interpolation using a chamfer distance" http://rd.springer.com/chapter/10.1007/BFb0033762 , but I don't have journal access at my current location to check.

Related

Is there any "Geometry Contour Line Algorithm"?

I want to find & draw contour lines like this.
Data is just List of (x,y,z) and only a few points (about 40~60) in there.
(x and y are position and z is height)
How can i find this contour line and point?
As a first approximation, you can admit that your function is piecewise planar over a triangulation of the data points.
The Delaunay triangulation technique can be used, but in this case, given the regular polar arrangement, I guess that a simple rule based on the polar arguments could do.
Interpolating inside the triangles and obtaining the horizontal sections is a simple matter. Unfortunately, this will produce a gross approximation and you will probably notice artifacts due to the coarseness of the polylines.
A possible cure is to smooth the polylines as a postprocessing step, for instance turning them to polyBeziers.
Another method, which I prefer, is to use a higher order interpolation method. For C1 continuity, you can compute estimates of the gradient at the given points and fit quadratic functions on the triangles. Then subdivide the triangles in sub-triangles, interpolate the function at the sub-vertices, and switch to the planar model in these sub-triangles.
As that looks like an irregular grid, you should first build a mesh around it (for instance, from a Voronoi tesellation).
For every triangle, take the maximum and minimum heights of its vertices and find out the heights of the contour lines in that range (for instance, if you are drawing contour lines every 10 units and the heights of a triangle go from 11.5 to 34.2, the contour lines passing through that triangle are at heights 20 and 30).
Then approximating the height function inside the triangle as a linear function, find out where those contour lines lay and draw them.
The data for the contour plot could be generated with a two-dimensional simplification of the marching cubes algorith, which is described here. In the simplification, squares are used instead of cubes and four sampled values are used for the interpolation instead of the the eight corners of the cubes.
The simplification is also termed marching squares.

Removing square objects

I have the image includes circular, elipsoidal, square objects and somethings like these. I want to get only circual objects. I applyed a filter by using Solidity and Enccentricity levels of objets but I could not remove square objects. Square objects which have not sharp corners have nearly same Solidity and Enccentricity level with circular objects.
My question is that is there any other parameter or way to detect square objects?
You can compare the area of the mask to its perimeter using the following formula
ratio = 4 * pi * Area / ( Perimeter^2 )
For circles this ration should be very close to one, for other shapes it should be significantly lower.
See this tutorial for an example.
The rationale behind this formula: circles are optimal in their perimeter-area ratio - max area for given perimeter. Given Perimeter, you can estimate radius of equivalent circle by Perimeter = 2*pi*R, using this estimated R you can compute the "equivalent circle area" using eqArea = pi*R^2. Now you only need to check the ratio between the actual area of the shape and the "equivalent area" computed.
Note: since Area and Perimeter of objects in mask are estimated based on the pixel-level discretization these estimates may be quite crude especially for small shapes. Consider working with higher resolution masks if you notice quantization/discretization errors.
There exists a Hough transform (imfindcircles) in order to find circles within an image which is what you needed in the first place.

How to get angle rotated of a 3D object from its transform martrix

I have a 3d object which is free to rotate along x,y and z axis and it is then saved as a transform matrix. In a case where the sequence of rotation is not known and the object is rotated for more than 3 times (eg :-if i rotate the object x-60degress, y-30 degrees, z-45 degrees then again x->30 degrees), is it possible to extract the angles rotated from the transform matrix?.I know that it is possible to get angles if the sequence of rotation is known, but if I have only the final transform matrix with me and nothing else, is it possible to get the angles rotated(x,y,and z) from the transform matrix ?
Euler angle conversion is a pretty well known topic. Just normalize the matrix orientation vectors and then use something like this c source code.
The matrix is the current state of things it has no knowledge of what the transformation has been in the past. It does not know how the matrix was built. You can just take the matrix into and decompose it into any pieces you like, as long as:
The data do not overlap. For example:Two X turns after each other is indistinguishable form each other (no way to know if its 1 2 or three different rotations summed).
The sequence order is known
A decomposition can be built out of the data (for example scale can be measured)

How to get the histogram orientation of a 'one' cell according to Dalal and Triggs?

I am trying to implement the method of Dalal and Triggs. I could implement the first stage compute gradients on an image, and I could create the code who walk across the image in cells, but I don't understand the logic behind this stage.
I know is necessary identify first between a signed (0-360 degrees) or unsigned (0-180 degrees) gradients.
I know I must create a data structure to store each cell histogram, whit n bins. I know what is a histogram, hence I understand I must visit each pixel, but I I don't fully understand about the method for classify each pixel, get the gradient orientation of this pixel and build the histogram with this data.
In short HOG is nothing but a dense representation of gradient orientations weighted by their strengths over a overlapped local neighbourhoods.
You asked what is the significance of finding each pixel gradient orientation. In an image the gradient orientation at each pixel indicates the direction of the boundary(edge between two textures) of the object at that location with respect to X and Y axis. So if you group the orientations of a patch or block or part of an object it represents the distribution of edge directions of object at that region in a very strong way or unique way... Now let us take a simple example, a circle if you plot the gradient orientations of a circle as a histogram you will get a straight line (Don't imagine HOG just a simple plot of gradient orientations) because the orientations of edges of circle ranges from 0 degrees to 360 degrees if u sampled at 360 consecutive locations, For a different object it is different, HOG also do the same thing but in a more sophisticated manner by dividing image into overlapping blocks and dividing each block into cells and making the histogram weighted by the strengths of the local gradients...
Hope it is useful ...

computer vision: extracting info about a shape given a contour (e.g. pointy, round...)

Given the 2D contour of a shape in the form of lines and vertices, how can I Extract Information from that?
like: Pointy, round, straight line.
Shape similarities with a given shape.
Code is not necessary, I am more interested in
concepts and the names of techniques involved to
guide my search....
Thanks in advance.
Image moments
One approach is to calculate the first and second order central moments of the shape described by the 2D contour. Using these values the elongation of the object can be calculated.
The central image moments can be combined to the seven moments of Hu, which are invariant to change in scale, rotation and translation (ie. they are very good for basic shape recognition). (More on image moments here).
Unitless ratio of perimeter and area
An other approach is to calculate the length of the perimeter (p) and the size of the inscribed area (a). Using these two values, the following ratio can be computed:
ratio = p^2 / (4 * pi * a)
The closer this ratio is to one, the more circle like is the described shape.
Other methods
Fourier descriptors
Ratio of shape area and the area of the convex hull of the shape
Another method of contour shape classification is topological aproach based on the "size function" That could be useful for global shape recognition, but not for extracting "local" features like pointy/round/straight.
http://en.wikipedia.org/wiki/Size_function
Basically slicing contour by parametrized line and counting number of connected components depending on parameter.
http://www.ingre.unimo.it/staff/landi/articoli/patrec.pdf
What I think you might be looking for is often called Blob or Connectivity Analysis, which I believe was first developed at SRI (Stanford Research Institute). Image moments are one component of this area.

Resources