필터 지우기
필터 지우기

Error while accessing the STATS properties in regionprops

조회 수: 1 (최근 30일)
if true
% code
STATS = regionprops(L, 'Extrema','Centroid');
if norm([STATS.Extrema(2,1), STATS.Extrema(2,2)]-[STATS.Extrema(1,1), STATS.Extrema(1,2)])<5
%statements
end
end
But I am getting an error stated below excatly on the line " if norm([STATS.Extrema(2,1), STATS.Extrema(2,2)]-[STATS.Extrema(1,1), STATS.Extrema(1,2)])<5 "
Field reference for multiple structure elements that is followed by more reference blocks is an error.
Can somebody please help how to solve this one? Thank you.

채택된 답변

Image Analyst
Image Analyst 2013년 12월 21일
STATS is s structure array, so you're going to have to refer to a certain index when you refer to is, like
extrema7 = STATS(7).Extrema;
Or you're going to have concatenate them all into one array
allExtrema = [STATS.Extrema];
allExtremaX = allExtrema (1:2:end);
allExtremaY = allExtrema (2:2:end);

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Image Segmentation and Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by