imregionalmax to find peaks in 3d. I get an error Index exceeds matrix dimensions.

2 ビュー (過去 30 日間)
As said in the title I have got an error using imregionalmax. I have two monotone variable xVec, yVec and a third dependent variable imageMag that is experimental value. imageMag is 31x593. I have used
x=xVec;
y=yVec;
z=imageMag;
mesh(x,y,z,'FaceColor','interp')
ix = find(imregionalmax(z));
hold on
plot3(x(ix),y(ix),z(ix),'r*','MarkerSize',24)
but it says that index exceeds matrix dimensions. Why?

採用された回答

Mike Garrity
Mike Garrity 2016 年 4 月 11 日
編集済み: Mike Garrity 2016 年 4 月 11 日
I'm just guessing, but that code snippet is assuming that x & y are full, 2D arrays. The mesh function allows for another case where they're vectors. From the name of your variables, I would guess that you've got that case.
If that's the case, you can expand the vectors out to 2D arrays using meshgrid :
[x,y] = meshgrid(xVec,yVec);
z = imageMag;
mesh(x,y,z,'FaceColor','interp')
ix = find(imregionalmax(z));
hold on
plot3(x(ix),y(ix),z(ix),'r*','MarkerSize',24)
  2 件のコメント
OldCar
OldCar 2016 年 4 月 12 日
編集済み: OldCar 2016 年 4 月 15 日
x and y are 1D vector (I think), they are 1x171 int32 and 1x51 int 32. I enclose xVec,yVec and imageMag. Thanks for your help. What do you think about?
Image Analyst
Image Analyst 2016 年 4 月 15 日
imregionalmax is meant to work with a volumetric image in 3D, not 1-D vectors.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by