I have written a code for finding centroid of connected components of an image and it gives an error.I tried to debug it but couldn't get a clue.How to solve that?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
So, the given is my code below.I need to find out the centroid of the connected components and it doesn't work.Also,I am supposed to save these centroids and I couldn't save it.The error that the gives is also given below- %%Computing Background Markers
bw = im2bw(Iobrcbr);
%compute connected components
CC=bwconncomp(bw);
lab=labelmatrix(CC);
%% FINDING CENTROID OF CONNECTED COMPONENTS(need to work on lab)
s=regionprops(lab,'centroid');
centroids=cat(1, s.Centroid);
figure
imagesc(lab)
hold on
plot(centroids(:,1),centroids(:,2), 'b*');
hold off
ERROR-Index exceeds matrix dimensions.
Error in actual (line 92) plot(centroids(:,1),centroids(:,2), 'b*');
4 comentarios
KSSV
el 25 de Oct. de 2016
It is working fine for my image....in your case what is Iobrcbr? Try changing image.
Prachi Sharma
el 25 de Oct. de 2016
Editada: Prachi Sharma
el 25 de Oct. de 2016
Respuestas (0)
Ver también
Categorías
Más información sobre Computer Vision with Simulink en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!