why my 3D image is not extruded in 3D software?

Hello, i have 3D image but when I view the image in the 3D software to be printed, the image does not extrude. here i attached my code and images. can anyone check on my code. Many thanks.
a = imread ('stomachgray.tif');
mask = zeros(size(a));
mask(100:end-100,100:end-100) = 1;
bw = activecontour(a,mask,1000);
c = im2double(bw);
shading flat
d = imgaussfilt3 (c,4);
colormap(bone)
h = hgtransform;
mesh(d*100, 'Parent', h, 'FaceColor', 'r' )
view(3)
lighting gouraud
camlight right
% Make it taller
set (gca, 'units', 'cent')
set(h, 'Matrix', makehgtform('scale', [10 10 500]))
[X,Y] = meshgrid(1:length(h));
surf2stl('stomachSurf7.stl',X,Y,d);
end

12 comentarios

KSSV
KSSV el 28 de Nov. de 2016
Have you tried minimizing the z axes limits in your software?
Zaitul
Zaitul el 28 de Nov. de 2016
Hi KKSV, do you mean the 3D software?
KSSV
KSSV el 28 de Nov. de 2016
Yes...in the software in which you are viewing.
Zaitul
Zaitul el 28 de Nov. de 2016
i think we cant set limit the z axis in the software. I've check it. (software: sapphire vagler)
KSSV
KSSV el 28 de Nov. de 2016
What I suspect is the z limit in your software is high so you are not able to view the extrusion.
Zaitul
Zaitul el 29 de Nov. de 2016
Make sense. When i want to load the image, a window appeared to say about the size of the image which is too big and i choose to resize the image. is that possible to set how big the extrusion in matlab? So that the image that i want to load in the 3D software is not huge.
Zaitul
Zaitul el 29 de Nov. de 2016
wait. is that means the limit of my software is too low?
KSSV
KSSV el 29 de Nov. de 2016
The z limit might be very high...
Zaitul
Zaitul el 5 de Dic. de 2016
i cant set the z limit. but can i know the height of my mesh extrusion? what function should i use?
Zaitul
Zaitul el 6 de Dic. de 2016
should i resize the image?
KSSV
KSSV el 6 de Dic. de 2016
Resizing will not help...I don't know about the software in which you are viewing.
I got the solution. but can i know if my code below is correct if i want to set the unit of the extrusion? unit that i want to use is cm.
[X,Y] = meshgrid(1:length(h));
set (gca, 'units', 'cent')
surf2stl('stomachSurfZ.stl',X,Y,d*100);

Iniciar sesión para comentar.

Respuestas (1)

DGM
DGM el 5 de Abr. de 2025
Editada: DGM el 5 de Abr. de 2025
The object height is clearly unit-scale. It's never changed.
c = im2double(bw); % it's unit-scale.
d = imgaussfilt3(c,4); % it's still unit-scale
The mesh plot is drawn at 100x height, and then it's stretched by another factor of 5, but that's entirely just an ephemeral plot. None of that transformation applies to d.
X and Y are derived as so:
[X,Y] = meshgrid(1:length(h)); % h is a scalar hgtransform
So X and Y are both scalar 1. Surf2stl() will treat those as the sample spacing. You end up with an STL with the x,y dimensions of the original image (i.e. 640x480), and a height of 1. The plot can completely be ignored.
More importantly for the task, surf2stl() will not create a closed 2-manifold from a simple surface. It's anybody's guess what a slicer will do when you give it a zero-thickness single-sided thing which cannot physically exist -- especially slicers from 2016. You either have to do the lofting yourself before giving it to surf2stl(), or you could use surf2solid() (also on the FEX). ... but now I'm curious.
EDIT: As to what a slicer would do if you fed it an open surface, these are what I tested:
  • Chitubox produces no warnings or errors on import or slicing. It just produces a bunch of garbage output (random floating layers that aren't connected to the object or other layers). Flying blind and getting getting junk results without explanation is part of the Chitubox experience.
  • The old MakerBot Studio just crashed, but that's basically the only thing it's good for.
  • IIRC, Cura produced a clear warning, but it also still let me slice it, generating different junk output (small random isolated curly paths floating in space).
  • Prusa Slicer produced a descriptive warning, a count of all the geometry errors, and properly returned an empty object (nothing to slice). Guess Prusa wins again.

Preguntada:

el 28 de Nov. de 2016

Editada:

DGM
el 5 de Abr. de 2025

Community Treasure Hunt

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

Start Hunting!

Translated by