Issue with regionprops returning no variable
이전 댓글 표시
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
채택된 답변
추가 답변 (1개)
Walter Roberson
2012년 1월 13일
0 개 추천
regionprops() will return no data if there are no non-zero entries in the matrix that is passed to it.
카테고리
도움말 센터 및 File Exchange에서 Surfaces, Volumes, and Polygons에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!