3D Boundary -- Identify points which lie outside the 3D volume?

조회 수: 13 (최근 30일)
Roger Breton
Roger Breton 2021년 12월 19일
답변: Yatharth 2024년 2월 21일
I am using scatter3 and trisurf to represent color images in CIE Lab (shown as data points), in relation to the output capabilities of a printing device (shown in raindow color) :
As you can see, there are points in this image which clearly lie outside of the 3D volume. (Saturated blues)
Would it be possible to show those points differently from those that lie inside the 3D volume?
I was thinking, perhaps, to add a white outline on those points, to denote the fact that they lie outside the 3D volume? So that they're very easy to see while rotating the view?
Or..., To add the "cherry on the icing", would it be possible to use the datatips to flag those points to the user, say with a different text color ? Here's my code :
% Redefine labels
h.DataTipTemplate.DataTipRows(1).Label = 'b';
h.DataTipTemplate.DataTipRows(2).Label = 'a=';
h.DataTipTemplate.DataTipRows(3).Label = 'L=';
% Show datatip
datatip(h, h.XData(1),h.YData(1),h.ZData(1));
And if I allow myself to dream... I would like, ideally, to calculate the Eucledian DeltaE distance from the gamut boundary to those out of gamut points, and have that value show up in the Datatip... Wow! I know, I know, the possibilities are endless.
Know that I plan to use this tool in class with my students, to demonstrate the handling of out of gamut colors, which is an abstract notion for many students...
I'm not looking for specific code samples unless it's very easy for you but some general direction, and I'll try to research the rest by myself... (and come back with further questions...)
I'm every grateful for the help I've been getting from this community and I would not want to abuse...

답변 (1개)

Yatharth
Yatharth 2024년 2월 21일
Hi Roger,
If you want to differntiate points that lie outside of the 3D volume from those that lie inside. You can do this by determining whether each point in your CIE Lab color space is inside or outside the 3D volume defined by the output capabilities of the printing device, and then plotting the points with different colors or markers.
Assuming you have the coordinates of the points in CIE Lab space and the vertices and faces of the 3D volume (triangular mesh), you can use a point-in-polygon (or point-in-polyhedron) approach to test if the points are inside or outside the volume.
Here is a general approach you can follow in MATLAB:
  1. Define the vertices and faces of the 3D volume (triangular mesh) that represents the output capabilities of the printing device.
  2. For each point in the CIE Lab color space, determine whether it is inside or outside the volume. You can use a function such as inpolygon for 2D or inpolyhedron (which may require custom implementation or a third-party function) for 3D.
  3. Plot the points that are inside the volume with one color or marker, and the points that are outside with a different color or marker.
% Let's assume 'lab_points' contains your CIE Lab data points as a Nx3 matrix
% And 'device_vertices' and 'device_faces' define your 3D volume
% Create a logical array to store whether each point is inside or outside
isInside = false(size(lab_points, 1), 1);
% Check each point - you may need to implement or find a suitable function
for i = 1:size(lab_points, 1)
isInside(i) = myPointInPolyhedronCheck(lab_points(i,:), device_vertices, device_faces);
end
% Plot the 3D volume of the printing device
trisurf(device_faces, device_vertices(:,1), device_vertices(:,2), device_vertices(:,3), ...
'FaceColor', 'cyan', 'FaceAlpha', 0.1);
hold on;
% Plot the points inside the volume
scatter3(lab_points(isInside, 1), lab_points(isInside, 2), lab_points(isInside, 3), ...
'MarkerEdgeColor', 'b', 'MarkerFaceColor', 'b');
% Plot the points outside the volume with a different color or marker
scatter3(lab_points(~isInside, 1), lab_points(~isInside, 2), lab_points(~isInside, 3), ...
'MarkerEdgeColor', 'r', 'MarkerFaceColor', 'r');
hold off;
% Implement this function or find a suitable one
function inside = myPointInPolyhedronCheck(point, vertices, faces)
% This function should determine if 'point' is inside the polyhedron
% defined by 'vertices' and 'faces'. You may need to write this function
% or find an existing implementation.
inside = false;
% ... (your point-in-polyhedron logic here)
end
Please note that myPointInPolyhedronCheck is a placeholder for a function that you would need to implement or find. There isn't a built-in MATLAB function that directly checks if a point is inside a 3D polyhedron
You can achieve adding a white outline by using the 'MarkerEdgeColor' property when calling scatter3. To make points easier to identify, you can increase their 'LineWidth' if they are outside the volume.
% Plot the points outside the volume with a white outline
scatter3(lab_points(~isInside, 1), lab_points(~isInside, 2), lab_points(~isInside, 3), ...
'MarkerEdgeColor', 'w', 'LineWidth', 1.5, 'MarkerFaceColor', 'r');
For the datatips customization, you can create a data cursor mode object and set its UpdateFcn to a custom update function.
I hope this helps!

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by