How can I analyze stl files and then redraw them in matlab? I need to write some code

조회 수: 5 (최근 30일)
Hello
I need help and guidance.
This is the goal. I need to write code in matlab to analyze some stl pictures and then redraw it in matlab. I could also use solidworks too, but I don't have a lot of experience in solidworks. Anything helps Thanks

답변 (2개)

KSSV
KSSV 2018년 6월 15일
  댓글 수: 1
JoshT_student
JoshT_student 2018년 6월 15일
Thank you, but I need more than that. I need some idea how to write code. I now have my data points from the curve fitting app. I just don't know how to use code to make the SEM image again. I attached my data points.

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


DGM
DGM 2025년 6월 30일
이동: DGM 2025년 6월 30일
For context:
I have no idea where this was going, but here's an implausible interpretation of "STL from pseudobinary image":
unzip stuff.zip % for the forum
% an antialiased RGB image
inpict = imread('SEM.png');
% get rid of extraneous channels
inpict = im2gray(inpict);
% binarize it and get the blob boundaries
mk = imbinarize(inpict);
[Vc,~,nblobs] = bwboundaries(mk);
% show boundary curves atop the mask
imshow(mk); hold on
for k = 1:nblobs
plot(Vc{k}(:,2),Vc{k}(:,1),'linewidth',2)
end
% flip a bunch of stuff
for k = 1:nblobs
% the source is an image, so we probably want to invert Y
Vc{k}(:,1) = size(inpict,1) - Vc{k}(:,1) + 1;
% flipping Y means we need to flip the boundary direction
% also need to remove duplicate vertex on closure
% B is [y x]; we need that flipped too
Vc{k} = Vc{k}(end-1:-1:1,[2 1]);
end
% consolidate the vertex list
V = cell2mat(Vc);
% construct the edge lists in the same direction
% the vertex lists in Vc don't need to be the same length
sz = cellfun(@(x) size(x,1),Vc); % length of each vertex list
szc = [0; cumsum(sz)];
E = zeros(0,2);
for k = 1:numel(Vc)
v = 1+szc(k):szc(k+1);
thisE = [v; circshift(v,-1)].';
E = [E; thisE];
end
% TRIANGULATION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% do a constrained triangulation to generate the triangles
T = delaunayTriangulation(V(:,1:2),E);
Warning: Duplicate data points have been detected and removed.
The Triangulation indices and constraints are defined with respect to the unique set of points in delaunayTriangulation.
F = T.ConnectivityList(isInterior(T),:);
V = T.Points;
% or better yet, use mesh2D (FEX #25555)
%[V,~,F,~] = refine2(V,E);
% clean up leftover points
[F V] = pruneunusedverts(F,V);
% display it using patch()
figure
patch('faces',F,'vertices',V, ...
'facecolor','w','edgecolor','k');
axis equal; grid on
xlabel('X'); ylabel('Y')
% EXTRUSION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% extrude the part into 3D
[F V] = extrude(F,V,50); % pick a thickness
% write to file
stlwrite(triangulation(F,V),'testfile.stl')
% display it using patch()
figure
patch('faces',F,'vertices',V, ...
'facecolor','w','edgecolor','none');
view(3); camlight; view(10,33)
axis equal; grid on
xlabel('X'); ylabel('Y'); zlabel('Z')
For other interpretations, see also:
Generate a lofted relief from a 2D depthmap image
Similar lofting or dithering for a lithophane
Yeah, but how would i do the lofting in 2012???
Extruding a logical image

카테고리

Help CenterFile Exchange에서 STL (STereoLithography)에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by