I have set of images and i have just considered the boundary of the image. In that boundary, i have obtained points as x and y coordinates, which shown below:
x= sortedx(i);
y=sortedy(i);
then i have the z coordinate as below:
z=2*ones(1,length(line));
(Note that z is the slice thickness which apparently 2mm, here)
My question is i have stacked mat files of above mentioned boundary images. Now, my intention is to export a 3D model to paraview by converting it to VTK format. Unfortunately, out of many mat to vtk conversion functions,i was not able to solve my issue). How can i export my 3D model?
Can someone pls help.

 Respuesta aceptada

Walter Roberson
Walter Roberson el 22 de Oct. de 2016

0 votos

You have boundary lines for each layer, but you do not have any information about the connection between the layers, so you cannot get a 3D geometry out without more work. How does the N'th point of the second layer relate to the N'th point of the first and third layers?

5 comentarios

Chathu
Chathu el 22 de Oct. de 2016
Thanks for your response Walter. Well, for each slice, all boundary points (x and y coordinates) are been calculated. Thickness of each slice is 2 mm (z coordinate). Does that what you asked for?
Walter Roberson
Walter Roberson el 22 de Oct. de 2016
Editada: Walter Roberson el 23 de Oct. de 2016
Consider:
%square
temp = ones(51,51);
slice1 = zeros(125,125); slice1(38:38+50,38:38+50) = temp;
[r1, c1] = find(slice1, 1, 'first');
b1 = bwtraceboundary(slice1, [r1, c1], 'E');
x1 = b1(:,1); y1 = b1(:,2); z1 = 0 * 2.2 * ones(size(x1));
subplot(1,3,1); imagesc(slice1); colormap(gray(2)); axis image; hold on; plot3(x1, y1, z1, 'r'); hold off
%circle
slice2 = zeros(125,125); [X,Y] = ndgrid(-62:62); slice2(X.^2+Y.^2 <= 15.^2) = 1;
[r2, c2] = find(slice2, 1, 'first');
b2 = bwtraceboundary(slice2, [r2, c2], 'SE');
x2 = b2(:,1); y2 = b2(:,2); z2 = 1 * 2.2 * ones(size(x2));
subplot(1,3,2); imagesc(slice2); colormap(gray(2)); axis image; hold on; plot3(x2, y2, z2, 'g'); hold off
%rotate the square
temp3 = imrotate(temp,45);
slice3 = zeros(125,125); slice3(26:26+72,26:26+72) = temp3;
[r3, c3] = find(slice3, 1, 'first');
b3 = bwtraceboundary(slice3, [r3, c3], 'SE');
x3 = b3(:,1); y3 = b3(:,2); z3 = 2 * 2.2 * ones(size(x3));
subplot(1,3,3); imagesc(slice3); colormap(gray(2)); axis image; hold on; plot3(x3, y3, z3, 'b'); hold off
So now we have three slices to be stacked together 2 mm apart on the z. The boundaries are (x1, y1, z1), (x2, y2, y2), (x3, y3, z3)
>> [length(x1),length(x2),length(x3)]
ans =
201 85 145
These are closed boundaries, which is why the length of the first is not 50*4 = 200. I am not sure at the moment why the third is shorter than the first. The second is smaller by way of construction -- it is deliberate in this example that the circle is smaller.
Now, should (x1(1), y1(1)) be considered to be connected to (x2(1), y2(1)), and that in turn should be connected to (x3(1), y3(1))? The first of those is the upper left corner of the square; the second of those is the top of the circle; the third of those is the top of the diamond. It might make some sense to connect the top of the circle to the top of the diamond, but the corresponding point on the square should be the middle of the top side, not the upper left corner.
Now, which point in (x2, y2) should (x1(100), y1(100)) and (x3(100), y3(100)) be connected to? There are only 85 points in (x2, y2) so you cannot go by corresponding point numbers.
I hope this demonstrates adequately that just knowing the boundary pixels of each slice is not enough to know how the layers connect together.
Chathu
Chathu el 23 de Oct. de 2016
Thank you so much for your detailed description including examples. Now i realized what you meant by it. What else would be necessary(could you kindly name some) if i just have coordinate points along boundary. ( i think i am little lost now). Thank you once again for your information though.
Walter Roberson
Walter Roberson el 23 de Oct. de 2016
The document indicates that paraview would accept files that contained a bunch of 3D lines, if we arrange to output such a file. I do not, however, know what kind of processing paraview can do with such a file.
What was it you were hoping that you could do with the slices in paraview?
With situations like this, I tend to think in terms of converting the outside surface into a triangular mesh, or into a quad mesh, but it does not appear to me that meshes are one of the input types that paraview accepts.
I wonder if it would make sense to simply create a volume that was NaN (or perhaps 0) everywhere except the boundary positions? That could exported as a "structured 3D grid".
Chathu
Chathu el 24 de Oct. de 2016
Thank you so much for your response Walter. I was hoping to get a 3D model using slices, in the Paraview. Anyway thank you so much for your kind suggestions.

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Preguntada:

el 22 de Oct. de 2016

Comentada:

el 24 de Oct. de 2016

Community Treasure Hunt

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

Start Hunting!

Translated by