I want to extract the cluster of points inside 3D box, is there any way one can do this in Mathematica?
-
2Please do explain in more detail what you want to achieve specifically (i.e. aks an answerable question). Consider providing a smaller data set if possible to take the work load of possible answerers. – Yves Klett Jul 06 '12 at 08:28
-
1My 2GB RAM was not enough. – István Zachar Jul 06 '12 at 16:15
-
It runs with 3 GB – Dr. belisarius Jul 06 '12 at 17:52
-
@Jay On this site we generally prefer to have posts either self contained or supplementary material hosted someplace where it is always retrievable (i.e., even after you delete the file from your dropbox) so that the question can help future users. I've uploaded your data file to a community github account for this reason. See also my answer here for why it was created and what the goals for the repository are. – rm -rf Jul 06 '12 at 18:06
-
@R.M I think you may get into copyrighting troubles ... – Dr. belisarius Jul 06 '12 at 18:55
-
@Jay, as others have mentioned, please consider adding some more information to this 'question'. E.g. why don't you compute the volume of each Cubiod and add that up? I am adding this since you asked me specifically to look at this question. – Jul 16 '12 at 22:04
-
1@Jay, I do not understand the question. You have a set of points, do you want the volume of the convex hull? – Jul 17 '12 at 23:38
-
@Jay, can you upload a picture of what you expect to see (generated with the other software)? – Jul 18 '12 at 20:00
-
@Jay your imported data seems simply to consist of a solid 30x30x30 block of cuboids, so extracting features is somewhat difficult. – Yves Klett Jul 19 '12 at 07:21
2 Answers
EDIT
OK, I think it is fair to say that the stuff below illustrates the quote "it seems Version 8 can not import the vtk cluster data directly" from the nice answer by @ruebenko .
------------------ old answer -----------------------------
It may happen that providing a smaller data set of your original data you lost the cluster points. If you zoom out of the center of the cube you can see that points fill the space rather uniformly - so there is no way for some of them to be more special than the others. It looks like there is no cluster. Could you please check and resubmit a verified data set with cluster points?
file = "http://dl.dropbox.com/u/68983831/Step_005.vtk";
data = Import[file, "VertexData"];
Manipulate[Graphics3D[Point[data],
PlotRange -> {{0 + r, 30 - r}, {0 + r, 30 - r}, {0 + r, 30 - r}},
Axes -> True, ViewPoint -> {2 Cos[r], 2 Sin[r], Sin[r]},
SphericalRegion -> True, ImageSize -> {400, 400}], {r, 14, 0}]

- 73,078
- 9
- 204
- 355
-
3this looks rather like an excercise in epileptogenic cristallography. – Yves Klett Jul 19 '12 at 08:15
-
3@YvesKlett I was hopping it may inspire Jay into providing us with correct data set ;-) – Vitaliy Kaurov Jul 19 '12 at 08:17
OK, there is good news and bad news: as it seems Version 8 can not import the vtk cluster data directly (and I filed this as a suggestion for future improvement). The good new is that this does not matter too much. Here is a starting point, for more details you will have to look at the vtk documentation and what is stored in your vtk files.
file = "http://dl.dropbox.com/u/68983831/Step_0990.vtk";
(* smaller file *)
(*file="http://dl.dropbox.com/u/68983831/Step_005.vtk";*)
in = Import[file, "Table"];
p1 = Position[
in, _?(If[Head[#] === String, StringMatchQ[#, "Cell*"],
False] &), {2}][[All, 1]]
(* {10, 114489} *)
p2 = Position[
in, _?(If[Head[#] === String, StringMatchQ[#, "Cluster*"],
False] &), {2}][[All, 1]]
(* {228968} *)
dim = in[[5, {2, 3, 4}]];
sp = in[[6, {2, 3, 4}]];
org = in[[7, {2, 3, 4}]];
Union[d = Join @@ in[[p1[[1]] + 1 ;; p1[[2]] - 1]]]
(* {0, 1, 2} *)
u2 = Union[d2 = Join @@ in[[p1[[2]] + 1 ;; p2[[1]] - 1]]]
(* {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, \
19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, \
36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, \
53, 54, 55, 56, 57, 58, 59, 60, 61, 62} *)
coords = Flatten[
Table[{i, j, k}, {i, org[[1]], dim[[1]] - 1, sp[[1]]}, {j,
org[[2]], dim[[2]] - 1, sp[[2]]}, {k, org[[3]], dim[[3]] - 1,
sp[[3]]}], 2];
Graphics3D[Point[Pick[coords, d, 1]]]

You can also use
Graphics3D[
Point[Pick[coords, d2, Alternatives @@ Select[u2, # > 7 &]]]]
to look at different sub-clusters.