Can you use islocalmax2 for a nxnxn grid where the values of that grid correspond to peaks in data density?
2 views (last 30 days)
Show older comments
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.
0 Comments
Answers (1)
Milan Bansal
on 2 May 2024
Edited: Milan Bansal
on 2 May 2024
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)
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!
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!