Can I use regionprops two times with two different variables in the same program at time?
1 view (last 30 days)
Show older comments
Zara Khan on 18 Sep 2018
Commented: Zara Khan on 19 Sep 2018
folder = pwd;
% folder = pwd;
filepattern = fullfile(folder, '*.png');
srcFiles = dir(filepattern);
numImages = length(srcFiles);
for k = 1 : numImages
fullFileName = fullfile(folder, srcFiles(k).name);
a = imread(fullFileName);
bwimg =bwareafilt(~a, 1);
theta = s(1).Orientation;
if theta>=0 && theta<90
circleCenterX = s1.Centroid(1);
diameters = mean([s1.MajorAxisLength s1.MinorAxisLength],2);
This is showing me error that multiple field reference. I am first rotating the images then again taking its property as centroid and orientation has been changed from the original image but its not working.
Matt J on 18 Sep 2018
This is showing me error that multiple field reference.
You need to show that error to us, too.
Saurabh Patel on 19 Sep 2018
Edited: Walter Roberson on 19 Sep 2018
Probably following lines have error.
circleCenterX = s1.Centroid(1); circleCenterY= s1.Centroid(2);
s1 might be nx1 struct with n greater than 1. My guess is bwareafilt is producing an oversegmented object. You can try the following:
Area = [s1.Area];
index = find(Area==max(Area));
circleCenterX = s1(index).Centroid(1);
diameters = mean([s1(index).MajorAxisLength s1(index).MinorAxisLength],2);
Find more on Image Processing Toolbox 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!