get eccentricity and metric values images

조회 수: 2 (최근 30일)
riki anohq
riki anohq 2021년 2월 21일
댓글: riki anohq 2021년 2월 22일
bro, I want to save the eccentricity and metric values of many images so that they form a table of eccentricity values and a metric of multiple images.
How do i make a loop?
source code:
clear; clc; close all;
%mfolder='E:\Kuliah\TesMatlalb\tesLATIH';
%filenames = dir(fullfile(mfolder, '*.png'));
%total = numel(filenames);
i = imread('21.png');
im = im2bw(i,.25);
bw = imcomplement(im);
bw = imfill(bw,'holes');
bw = bwareaopen(bw,50);
%figure,imshow(bw);
[bw,num] = bwlabel(bw);
bbox = zeros(num,4);
RGB4 = i;
for k = 1:num
bw2 = bw==k;
[B,L] = bwboundaries(bw2,'noholes');
stats = regionprops(L,'All');
perimeter = cat(1,stats.Perimeter);
area = cat(1,stats.Area);
eccentricity = cat(1,stats.Eccentricity);
metric = 4*pi*area/perimeter^2;
bbox(k,:) = cat(1,stats.BoundingBox);
end
RGB5 = insertShape(i, 'Rectangle', bbox, 'LineWidth', 1);
figure, imshow(RGB5);

채택된 답변

Image Analyst
Image Analyst 2021년 2월 21일
Index your variables with k:
area(k) = cat(1,stats.Area);
eccentricity(k) = cat(1,stats.Eccentricity);
metric(k) = 4*pi*area/perimeter^2;
  댓글 수: 1
riki anohq
riki anohq 2021년 2월 22일
Thanks, i use this
metric(1,k) = 4*pi*area/perimeter^2;

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Image Data Workflows에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by