I have a 1×26 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; endend
%Cal
Any help would be greatly appreciated.
Best Answer