Using a loop, how do I access/use values from a structure array that is within a cell array?
显示 更早的评论
I have a 1x26 cell that contains the regionprops measurements for 26 images (images with shapes), and within each image measurement cell is a structure array containing its measurements. I am trying to take the area and perimeter values for each image and put it in the following equation: SF = (4 * pi * Area) / (Perimeter^2), and save these values into another array. However, some of the images have multiple labeled objects, and so multiple Area/Perimeter measurements. I can get an individual value by using:
if true
% S = (4 * pi * measurements{i}(k).Area) / ((measurements{i}(k).Perimeter) ^ 2);
%
D = dir;
Image = cell(1, numel(D));
labeled = cell(1, numel(D));
for i = i : numel(D)
Image{i} = imread(D(i).name); %cell array with 26 images
labeled{i} = bwlabel(Image{i}, 8);
measurements{i} = regionprops(labeled{i}, Image{i}, 'all');
end
%
AREA = cell(1, numel(D));
PERIMETER = cell(1, numel(D));
a = cell(1, numel(D));
for k = 1 : numel(D)
a{k} = struct2cell(measurements{k});
numOfmeasurements{k} = length(a{k});
for i = 1: numOfmeasurements{k}
AREA{i} = measurements{k}(i).Area;
PERIMETER{i} = measurements{k}(i).Perimeter;
end
end
%Cal
Any help would be greatly appreciated.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Image Segmentation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!