How to find the distance of a object from centre line of the image.
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
rupam baruah
el 8 de Oct. de 2015
Respondida: Image Analyst
el 3 de Mzo. de 2017
Sir, I have a binary image with one object. Is it possible to find the distance of the centroid of the object from the center line of the image by using 'regionprop' function? I want to know how can I find 'a' and 'b' in the image. I have attached the image. Thank You.
0 comentarios
Respuesta aceptada
Image Analyst
el 8 de Oct. de 2015
Just get the centroid and then get the distances
labeledImage = bwlabel(binaryImage);
[rows, columns] = size(binaryImage);
measurements = regionprops(labeledImage, 'Centroid');
b = abs(rows/2 - measurements.Centroid(2));
deltaX = measurements.Centroid(1) - columns/2;
a = sqrt(b^2 + deltaX^2)
2 comentarios
Image Analyst
el 1 de Mzo. de 2017
regionprops() can give both Centroid which is the centroid based on the shape alone (ignoring the gray levels), and WeightedCentroid which is the centroid taking into account the gray levels at each pixel in the shape.
Image Analyst
el 2 de Mzo. de 2017
Simply white out the bottom black thing, then threshold to find dark stuff, then get the centroid in pixels, Then convert pixels to mm and divide by the frame time. If you still have questions then see my Image Segmentation Tutorial http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862 If you still have questions after adapting my tutorial to your images, then post in a brand new question.
Más respuestas (1)
Image Analyst
el 3 de Mzo. de 2017
Seems like maybe you got stuck. So see the attached file.
0 comentarios
Ver también
Categorías
Más información sobre Image Segmentation and Analysis en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!