How to plot a 2D histogram with data for x, y and z intensity values (without mesh grid)
6 ビュー (過去 30 日間)
古いコメントを表示
I need to plot a 2D projection image (data is attached), I previously used the mathworks code below but it created the image in the format of a 'matlab.primative.graphic.image' which cannot be analysed further. I have attached an image of what I am trying to recreate in matlab, here is what the 2D image looked like as an output from the .root software. I need to analyse this image to find the with of the central object (I need it in uint, grayscale or double format)
.



C = readmatrix('No_shift.xlsx');
D = readmatrix('5cm_Shift.xlsx');
xC = C(:,1);
yC = C(:,2);
zC = C(:,3);
xD = D(:,1);
yD = D(:,2);
zD = D(:,3);
n = 290.39;
[Xc, Yc] = meshgrid(linspace(min(-150),max(150),n), linspace(min(-150),max(150),n));
Zc = griddata(xC,yC,zC,Xc,Yc);
[Xd, Yd] = meshgrid(linspace(min(-150),max(150),n), linspace(min(-150),max(150),n));
Zd = griddata(xD,yD,zD,Xd,Yd);
figure (1) % Plot the original image C
GlobalPosZX_C = imagesc(Zc);
title('O R I G I N A L I M A G E: Unshifted')
figure (2) % Plot the shifted image 5cm
GlobalPosZX_D = imagesc(Zd);
title('S H I F T E D : 5cm Shift')
0 件のコメント
回答 (2 件)
dpb
2023 年 8 月 15 日
移動済み: dpb
2023 年 8 月 16 日
C = readmatrix('No_shift.xlsx');
n = 290.39;
[Xc, Yc] = meshgrid(linspace(-150,150,n), linspace(-150,150,n));
Zc = griddata(C(:,1),C(:,2),C(:,3),Xc,Yc);
GlobalPosZX_C = imagesc(Zc);
I=mat2gray(GlobalPosZX_C.CData);
figure
imshow(I)
What you mean can't further analyze it? Reference <the properties> to get access to the image object.
Of course,
all(GlobalPosZX_C.CData==Zc,'all')
anyway, so you can do whatever you want with the initial array directly; the visual in imagesc is really totally immaterial.
Steven Lord
2023 年 8 月 16 日
I think what you want is the xcorr2 function from Signal Processing Toolbox. I think if you adapt the "Align Two Images Using Cross-Correlation" example on that documentation page to use your data instead of the sample image data and tie the values xcorr2 returns in the example to your X and Y coordinate data you could show what you're trying to show.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Histograms についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!