data = [1,1,1,2,1,1,3,3,2,4,4,4,5,6,7,8,8,9,9,9,8,8,7,7,5,5,4,6,6,2,5,9,9,9,9,7,7,7,7,8,8,4,4,5,5,6,6,4,4,5,5,1,1,2,1,3,3,1]
uniqueData = unique(data)
appearances = zeros(1000, 2);
appearances(:, 1) = [1 : size(appearances, 1)]';
for k = 1 : length(uniqueData)
thisValue = uniqueData(k);
props = regionprops(data == thisValue, 'Area');
for k2 = 1 : length(props)
appearances(props(k2).Area, 2) = appearances(props(k2).Area, 2) + 1;
end
end
appearances
lastBin = find(appearances(:, 2) > 0, 1, 'last');
appearances = appearances(1:lastBin, :)
0 Comments
Sign in to comment.