How can I find the midpoint of the object in my Image, and the distance of the midpoint to the center of the image?

5 vues (au cours des 30 derniers jours)
I have this Image attached, where I'm trying to find the mid point of the white object (bean), and then calculate the distance from that point to the center of the image. I have found the center of the image but I cannot find the midpoit of that object. I have tried using bwlabel(), regionprops(), blobsDemo(), for the last hours but no luck so far.
Thanks

Réponses (1)

Miguel Feitor
Miguel Feitor le 9 Jan 2020
Modifié(e) : Miguel Feitor le 9 Jan 2020
Solved! Using the code below on my secondary PC, for some reason I keep getting the error "iptcheckconn.m" is now inaccessible.", when I use some funcitons on my working PC, I have tried solving it but no luck so far.
clear;
close all;
clc;
I = imread('C:\DilatedRedBeanv0.png');
Ibw = im2bw(I);
Ibw = imfill(Ibw,'holes');
Ilabel = bwlabel(Ibw);
stat = regionprops(Ilabel,'centroid');
imshow(I); hold on;
for x = 1: numel(stat)
plot(stat(x).Centroid(1),stat(x).Centroid(2),'ro');
end

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by