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

5 ビュー (過去 30 日間)
JoshT_student
JoshT_student 2018 年 6 月 15 日
移動済み: DGM 2025 年 6 月 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 Center および File ExchangeSTL (STereoLithography) についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by