Issue with regionprops returning no variable
Show older comments
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
Accepted Answer
More Answers (1)
Walter Roberson
on 13 Jan 2012
0 votes
regionprops() will return no data if there are no non-zero entries in the matrix that is passed to it.
Categories
Find more on Surfaces, Volumes, and Polygons in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!