Indexing for partial matrix
4 次查看(过去 30 天)
显示 更早的评论
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?
0 个评论
回答(1 个)
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
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
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!