필터 지우기
필터 지우기

Indexing for partial matrix

조회 수: 2 (최근 30일)
Stephen Thompson
Stephen Thompson 2020년 7월 17일
댓글: Stephen Thompson 2020년 7월 21일
I have a 140 x 2000 matrix. It contains a blob of area (I know the linear indices) that has known peaks. I want to find the maximum peaks in part of the blob. Specifically I want to find the maximum peak in rows 1-77 and the maximum in rows 78-140 of the blob. There may be other blobs with other peaks, so it has to be by blob area.
Should I generate the linear indices for each section (e.g. all columns, rows 1:77) and then find which are common with the blob indices? How would I do that?

답변 (1개)

Matt J
Matt J 2020년 7월 17일
편집: Matt J 2020년 7월 17일
[upperBlob,lowerBlob]=deal(yourMatrix);
upperBlob(78:end,:)=-inf;
lowerBlob(1:77,:)=-inf;
[imax1,jmax1]=find(upperBlob==max(upperBlob(:))); %upper blob max
[imax2,jmax2]=find(lowerBlob==max(lowerBlob(:))); %lower blob max
  댓글 수: 3
Matt J
Matt J 2020년 7월 21일
편집: Matt J 2020년 7월 21일
I don't see why it wouldn't have worked. The area outside your blobs appears to be zero, while the area inside the blobs appears to be greater than zero, so the maxima I've computed above would inherently have to fall within the blobs. Regardless, you could exclude the background with a few additional lines:
A=-inf(size(yourImage));
A(blobIndices)=yourImage(blobIndices):
[upperBlob,lowerBlob]=deal(A);
upperBlob(78:end,:)=-inf;
lowerBlob(1:77,:)=-inf;
[imax1,jmax1]=find(upperBlob==max(upperBlob(:))); %upper blob max
[imax2,jmax2]=find(lowerBlob==max(lowerBlob(:))); %lower blob max
Stephen Thompson
Stephen Thompson 2020년 7월 21일
It is my fault for not explaining the problem well enough. Another example with 2 blobs - but I still would want them classed by row (corresponds for frequency but axes left generic) and by blob.
There could be multiple blobs with peaks above and below the row cut line, but I want to separate them into maxima by blob and by dichotomous row grouping, So it does have to be separated on a per-blob basis. Now that I can find the subscripts (ind2sub) for the blobs I can solve the problem. Thank you though for your solution.

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

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by