Can you use islocalmax2 for a nxnxn grid where the values of that grid correspond to peaks in data density?

조회 수: 3 (최근 30일)
I am trying to pickout peaks of data density. I fit my data to a kernel density estimation using the mvksdensity function.
I then get a matrix, Z, the size of my grid where the values correspond to the density of the data in the 3D variable space.
My question is, can I use islocalmax2 to pick out peaks in this nxnxn matrix Z, or does it only work in 2 dimensional arrays.
The documentation lists the input data can be a multidimensional array, though I'm not sure if it works with a page size greater than 1.
My goal is to calculate the prominence of of these peaks as well so if anyone has any resources related to that in more than 2 dimensions, that would be very helpful.
I've also used the imregional max function from the image processing toolbox, but the user doesn't have control over any parameters for the peaks.

답변 (1개)

Milan Bansal
Milan Bansal 2024년 5월 2일
편집: Milan Bansal 2024년 5월 2일
Hi Poison Idea fan,
The function islocalmax2 is compatible with multidimensional arrays, that means you can use it to get the peaks in the n x n x n matrix "Z" as well. The function will return the output as a 3 dimensional "logical" array with same size as that of "Z". The function will find local maximas for each 2-D layer (n x n) in "Z".
A = rand(100, 100, 100); % create a random 3D matrix of size 100 x 100 x 100
TF = islocalmax2(A);
size(TF)
ans = 1x3
100 100 100
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
You can also calculate the "prominence" using the same function as shown below.
[TF, P] = islocalmax2(A); % P is the prominence
Please refer to the following documentation link to learn more about islocalmax2 function.
Hope this helps!
  댓글 수: 1
Poison Idea fan
Poison Idea fan 2024년 5월 2일
Hi Milan,
The issue for me is that it's finding the LM for each layer and not considering the relative values in the Z direction. Unless you have a way to suggest taking the maxima of each 2D layer and comparing them somehow, I am still stuck.
PIF

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

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품


릴리스

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by