Printing row of maximum value of a column

1 visualización (últimos 30 días)
ennes mulla
ennes mulla el 8 de Jul. de 2021
Hi.
I am processing image data for an experiment I have where i try to track the centroid of laser beam on a detector.
I was able to extract the data and process them to find the areas of all shapes in the image and to find all their centroid. The centroid has two coordinates X and Y. I have created an array that has 3 columns, where the columns are area of each shape and the coordinate of its centeroidm as following: 'Area', 'X','Y'. I have used the following code:
directory = 'C:\Users\anask\Desktop\test\';
files = dir([directory '/*.jpg']);
[~,index] = sortrows({files.date}.'); files = files(index); clear index;
auxx = [];
auxy = [];
for x = 1: numel(files)
A= imread([directory '/' files(x).name]);
%Convert the image ino binary image
Ibw = im2bw(A);
%Fill image regions and holes
Ibw = imfill(Ibw,'holes');
Ilabel = bwlabel(Ibw);
%find the centroid
stat = regionprops(Ibw,'Area','Centroid'); %Note here stat is a struct array
end
Till here I have the stat array that has Area and Centroid coorinate but for all images and I want it to apply the following processing to every image
%Creating new array that have Area, X-coordinate, Y-coordinate
area = cat(1,stat.Area)
Coor = cat(1,stat.Centroid)
%Combaining the results in one Array
Array = cat(2,area,Coor)
%Adding a header to the array
header = {'Area','x','y'};
Array = [header; num2cell(Array)];
Then I want to append in a new matrix or Array that has the whole row of max 'Area' from every image.
Can someone help me please?

Respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by