Issue with regionprops returning no variable
Mostrar comentarios más antiguos
I'm having trouble going through a for loop that's calculating a centroid location using the previous images centroid location as a selection point for the next to bwselect. I'm not sure why, but sometimes it will use the same points for a selection point, and get nothing appended to the centroids variable. The images I'm using are of a varying shaped tube, each image a section of tube. I'm attempting to find a line that passes through each centroid of each slice. imagedata is a cell array of the binary images of the pipe.
Here's my question: What's causing this hiccup? It's not an issue with rounding. The regionprops command simply isn't returning a value sometimes, and is others. It cycles through the correct number of times, but merely stops appending onto the centroids variable. Anyone have any suggestions?
[x,y,BW2,idx,xi,yi] = bwselect(~imagedata{n}, 4);
close gcf % closes selection window
centroids = [];
for i = n:p
clc
[x,y,imbw{i},idx,xi,yi] = bwselect(~imagedata{i},xi,yi,4); % uses prior centroid location and writes new centroid to variable
s{i} = regionprops(imbw{i},'centroid'); % necessary intermediary due to regionprops mechanics
centroids = cat(1,centroids,s{i}.Centroid); % appends new centroid to list of centroids
end
Respuesta aceptada
Más respuestas (1)
Walter Roberson
el 13 de En. de 2012
0 votos
regionprops() will return no data if there are no non-zero entries in the matrix that is passed to it.
1 comentario
Micheal
el 13 de En. de 2012
Categorías
Más información sobre Surfaces, Volumes, and Polygons en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!