Finding areas of data based on value threshold and contiguous size, both height and length.

1 次查看(过去 30 天)
Hi,
I would like to find the indices of this matrix where values are >3 and are larger than 3 x 5 in size. I have tried using the Image Processing Toolbox and binaryVector...
Any help much appreciated.
A = [2.5 2.5 2.5 2.5 2.5 2.5 2.5 2.5 2.5 2.5 2.5 2.5;
2.5 2.5 2.5 2.5 2.5 2.5 2.5 2.5 2.5 2.5 2.5 2.5;
2.5 2.5 3.5 3.5 3.5 3.5 3.5 3.5 2.5 2.5 2.5 2.5;
2.5 2.5 3.5 3.5 3.5 3.5 3.5 3.5 2.5 2.5 2.5 2.5;
2.5 2.5 3.5 3.5 3.5 3.5 3.5 3.5 2.5 2.5 2.5 2.5;
2.5 2.5 3.5 3.5 3.5 3.5 3.5 3.5 2.5 2.5 2.5 2.5;
2.5 2.5 2.5 2.5 2.5 2.5 2.5 2.5 2.5 2.5 2.5 2.5;
2.5 3.5 2.5 2.5 2.5 2.5 2.5 2.5 2.5 2.5 2.5 2.5;
2.5 2.5 2.5 2.5 2.5 2.5 2.5 2.5 2.5 3.5 3.5 2.5;
2.5 2.5 2.5 2.5 2.5 2.5 2.5 2.5 2.5 3.5 3.5 2.5;
2.5 2.5 3.5 2.5 2.5 2.5 2.5 2.5 2.5 2.5 2.5 2.5;
2.5 2.5 2.5 2.5 2.5 2.5 2.5 2.5 2.5 2.5 2.5 2.5]

回答(1 个)

Jan
Jan 2021-4-23
Start with:
B = (A > 3);
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 1 1 1 1 1 1 0 0 0 0
0 0 1 1 1 1 1 1 0 0 0 0
0 0 1 1 1 1 1 1 0 0 0 0
0 0 1 1 1 1 1 1 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 1 1 0
0 0 0 0 0 0 0 0 0 1 1 0
0 0 1 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
Now mention, what you have tried with the image processing tooolbox and which problems occurred.
  1 个评论
Nick Ward
Nick Ward 2021-4-23
Hi Jan,
Thank you. So, I have the binary image you replied with.
I now want to find the indices of the largest area of 1s...
I used bwlabel to label each region >3, and then regionprops of area and perimeter to exclude anything below the 3 x 5 array threshold I require. I can only retrieve every value >3.
Ideally, I would like to dump each region of data >3 and greater than 3 x 5 size into new matrices and output their indices. The data set is I am working on is logged temperature from a oceanographic mooring - I am looking for large water masses >3 C, for context.
I have tried using this code from Image Analyst;
% Find logical vector of AW regions (>3 degrees)
binaryVector = A > 3
% Label each region with a label - an "ID" number.
[labeledVector, numRegions] = bwlabel(binaryVector)
% Measure lengths of each region and the indexes
measurements = regionprops(labeledVector, A, 'Area', 'PixelValues');
% Find regions where the area (length) are 20 or greater and
% put the values into a cell of a cell array
for k = 1 : numRegions
if measurements(k).Area >= 20
% Area (length) is 3 or greater, so store the values.
ca{k} = measurements(k).PixelValues;
end
end
% Display the regions that meet the criteria:
celldisp(ca)

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Convert Image Type 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by