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

조회 수: 2 (최근 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