islocalmax2: problems understanding 'MinProminence'

3 visualizaciones (últimos 30 días)
Andre Zeug
Andre Zeug el 21 de Mzo. de 2025
Comentada: Mathieu NOE el 14 de Abr. de 2025
I want to find local maxima in a 2D intensity image ("cell1.mat") and used the following strategy:
% load data
load('cell1.mat')
% edge preserving smoothing
ds = imbilatfilt(d, .01*(max(d(:))-min(d(:)))^2,10);
% find local max
[TF,P] = islocalmax2(ds,'MinProminence',2000,'MinSeparation',1,'ProminenceWindow',10);
myList = find(TF);
[row,col] = ind2sub(size(ds),myList);
The result can be visualized by
figure,
surf(dsz,'EdgeColor','none','FaceColor','interp');
colormap('jet')
hold on
for np=1:length(myList);
plot3(col(np),row(np),dsz(row(np),col(np)),'o','MarkerEdgeColor','b','MarkerFaceColor','none', 'MarkerSize',12);
end
axis tight
Now I wonder why islocalmax2 found so many small peaks unless I set the 'MinProminence' option to 2000.

Respuestas (2)

Mathieu NOE
Mathieu NOE el 21 de Mzo. de 2025
hello
just fyi I tried with this fex submission (and no smoothing )
result : (6 peaks)
code :
load('cell1.mat')
d = double(d);
contourf(d)
colorbar
hold on
[pks,locs_y,locs_x]=peaks2(d,'MinPeakHeight',max(d(:))*0.75,'Threshold',max(d(:))*0.02);
for k = 1:numel(pks)
plot(locs_x(k),locs_y(k),'r+','markersize',15);
end
  1 comentario
Mathieu NOE
Mathieu NOE el 21 de Mzo. de 2025
another basic alternative , extracting contour lines x,y coordinates and plotting the centroids
load('cell1.mat')
d = double(d);
contourf(d,8)
colorbar
hold on
% extract isoclines
level = max(d(:))*0.75;
[C,h] = contour(d,level*[1 1]);
[m,n] = size(C);
ind = find(C(1,:)==level); % index of beginning of each isocline data in C
ind = [ind n+1]; % add end (+1)
for k = 1:numel(ind)-1
xc = C(1,ind(k)+1:ind(k+1)-1);
yc = C(2,ind(k)+1:ind(k+1)-1);
plot(xc,yc,'m');
% centroid
Xce = mean(xc);
Yce = mean(yc);
plot(Xce,Yce,'+r','markersize',15);
end
hold off

Iniciar sesión para comentar.


Andre Zeug
Andre Zeug el 21 de Mzo. de 2025
Thank you Mathieu for your alternative approaches. I will definitely give them a try.
I still wonder why the 'MinProminence' property of the islocalmax2 function does not seem to work as described in the doc.
  7 comentarios
Andre Zeug
Andre Zeug el 13 de Abr. de 2025
Not yet, I had a long discussion with MATLAB tech support and we found that the documentation for islocalmax2 was a bit misleading in how it described prominence estimation.
A problem arises when applying islocalmax2 to noisy data, such that the radius for the lowest closed contour around the local maximum converges to zero, so that the islocalmax2 function returns the peak value but not its prominence.
The doc is/will be changed, but the problem of how to get the prominence of local maxima for noisy data is not yet solved by islocalmax2.
Mathieu NOE
Mathieu NOE el 14 de Abr. de 2025
and what about using the other alternatives ?

Iniciar sesión para comentar.

Productos


Versión

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by