필터 지우기
필터 지우기

Extrude binary image at an angle

조회 수: 3 (최근 30일)
James Marshall
James Marshall 2022년 1월 30일
답변: Maneet Kaur Bagga 2024년 1월 3일
I wish to extrude the following binary image with some angle about the x and y axes that I have to hand, they are effectvely -50 and +50 degrees respectively. The background is that this is a vessel cross-section, but we are not looking down it perpendicularly which I wish to do to calculate axial fluid flow, so I wish to rotate it, I have done this with the image itself using imwarp, but the image quality was too poor for this to then be useful so I am hoping to idealise the base image of the vessel which has not been processed, and then gain a perpendicular cross-section using the angles which I have found and stated above. I have looked into the surf, cylinder, extrude functions but can't get any of them to quite work, any help would be greatly appreciated.

답변 (1개)

Maneet Kaur Bagga
Maneet Kaur Bagga 2024년 1월 3일
Hi James,
As per my understanding, the "extrude" function is used for creating and analyzing 3D antenna geometries. It would not directly accept a binary image and therefore is not used for general image processing cases, therefore to simulate the extrusion of a binary image in MATLAB, create a 3D matrix where each slice along the third dimension is a copy of the binary image, effectively creating a 3D block with the shape of the binary image. Then, using "isosurface" function extract the surface mesh of this 3D shape.
After creating the 3D mesh, apply the rotation transformation to the vertices "v" using the rotation metrices and display the rotated 3D model using the "patch" function.
Please refer to the code below for reference:
% Extrude the binary image
thickness = 10; % Define the thickness of the extrusion
[z, y, x] = ndgrid(1:thickness, 1:size(binaryImage, 1), 1:size(binaryImage, 2));
extrudedImage = repmat(binaryImage, [1, 1, thickness]);
% Use isosurface to extract the 3D mesh of the extruded shape
[F, V] = isosurface(x, y, z, extrudedImage, 0.5); % Extract the surface
% Apply the rotation
angleX = deg2rad(-50);
angleY = deg2rad(50);
Rx = [1, 0, 0; 0, cos(angleX), -sin(angleX); 0, sin(angleX), cos(angleX)]; % Rotation matrix around x-axis
Ry = [cos(angleY), 0, sin(angleY); 0, 1, 0; -sin(angleY), 0, cos(angleY)]; % Rotation matrix around y-axis
V_rotated = (Ry * (Rx * V.')).'; % Apply the rotations
Please refer to the MATLAB Documentation below for better understanding of the functions:
Hope this helps!

카테고리

Help CenterFile Exchange에서 Scalar Volume Data에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by