Line/FreeDrawROI is not visible in axis w/ Point Cloud

조회 수: 4 (최근 30일)
Dennis Premoli
Dennis Premoli 2023년 5월 28일
댓글: DGM 2023년 5월 28일
Hi everyone,
I have a 3D point cloud in a Matlab App Figure. I want the user to be able to draw around an area of interest and for this to be isolated/zoomed or something like that. The problem is that if the axes are empty, the ROI works. If the PC is plotted within it, then the ROI UI appears (crosshairs) and I can draw one, but it won't show.
Testing this out in a normal script, it appears that the same issue occurs. With the same code, a couple of times I tried the ROI appeared to behave properly and show in the 3D space, while many other times I reran the same code, the ROI just never appears. I was also trying to figure out whether it was a UISTACKing issue but it isn't. The ROI object is created and placed in front, but all of its properties appear empty.
Could this be a bug? I have tested this in 2022a and 2023a, same issue.
clear
clc
% Generate random 3D point cloud data
numPoints = 10;
x = rand(numPoints, 1);
y = rand(numPoints, 1);
z = rand(numPoints, 1);
% Plot the point cloud
scatter3(x, y, z, 'filled');
xlabel('X');
ylabel('Y');
zlabel('Z');
axis equal;
grid on;
% Create a freehand ROI
Line = drawline(gca);

답변 (1개)

DGM
DGM 2023년 5월 28일
편집: DGM 2023년 5월 28일
I haven't checked the documentation, but I seem to recall that the images.roi tools need an image object in the given axes. It's the extent and resolution of the image object that defines the size of the generated mask and the relative position of the drawn object in the mask.
% Generate random 3D point cloud data
numPoints = 10;
x = rand(numPoints, 1);
y = rand(numPoints, 1);
z = rand(numPoints, 1);
% Plot the point cloud
scatter3(x, y, z, 'filled');
xlabel('X');
ylabel('Y');
zlabel('Z');
axis equal;
grid on;
hold on;
% put a dummy image in the xy plane
% some given number of pixels stretched over the axes area
hi = image(xlim,ylim,[100 100]);
hi.AlphaData = 0; % with zero opacity
% Create a freehand ROI
roi = drawline(gca);
That will allow you to use drawline(), although you're still only going to be working in the xy plane. Also, setting alpha may tend to make the ui very laggy if you're using software rendering. Again, setting the visibility property of the image object will also disable the ROI object.
  댓글 수: 4
Dennis Premoli
Dennis Premoli 2023년 5월 28일
Here's a simple example where this works realiably in a 2D graph in 2022a and 2023a.
DGM
DGM 2023년 5월 28일
Strange. That does seem to work, but using scatter3() with view(2) doesn't. Either way, it will still error if you try to use createMask.

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

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by