Zorbing

[Medtec] boneSurfaceSegmentation.m

Jun 11th, 2013
298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 2.62 KB | None | 0 0
  1. %% Darstellung von 3D Intensitaetsbildern
  2. % 1.
  3. load('CTHeadVolume');
  4.  
  5. % 2.
  6. s = size(imageVolume);
  7. montage(reshape(uint8(imageVolume), s(1), s(2), 1, s(3)));
  8.  
  9. % 3.
  10. implay(reshape(uint8(imageVolume), s(1), s(2), 1, s(3)));
  11.  
  12.  
  13. %% Segmentierung der Knochenstruktur
  14. % 1.
  15. imageVolumeBin = zeros(s(1), s(2), s(3), 'uint8');
  16.  
  17. % 2.
  18. boneLevel = 200;
  19.  
  20. % 3.a)
  21. idx = find(imageVolume > boneLevel);
  22. % 3.b)
  23. imageVolumeBin(ind2sub(size(imageVolumeBin), idx)) = 255;
  24.  
  25. % 4.
  26. montage(reshape(imageVolumeBin, s(1), s(2), 1, s(3)));
  27. % Qualitaet passt.
  28.  
  29.  
  30. %% Nachbearbeitung der Segmentierung
  31. %
  32. imageProcBin = imageVolumeBin;
  33. % 1.a)
  34. sphere = strel('ball', 4, 4);
  35. % 1.b)
  36. imageProcBin = imdilate(imageProcBin, sphere);
  37. % 1.c)
  38. imageProcBin = imerode(imageProcBin, sphere);
  39. figure
  40. montage(reshape(imageProcBin, s(1), s(2), 1, s(3)));
  41.  
  42. % 2.a)
  43. CC = bwconncomp(imageProcBin, 26);
  44. % 2.b)
  45. maxCompId = 1;
  46. maxCompSize = numel( CC.PixelIdxList{maxCompId} );
  47. for id = 2 : CC.NumObjects
  48.     if numel( CC.PixelIdxList{id} ) > maxCompSize
  49.         maxCompSize = numel( CC.PixelIdxList{id} );
  50.         maxCompId = id;
  51.     end
  52. end
  53. posBoneStructure = CC.PixelIdxList{maxCompId};
  54. % 2.c)
  55. imageProcBin = zeros(s(1), s(2), s(3), 'uint8');
  56. imageProcBin(posBoneStructure) = 255;
  57.  
  58. % 3.
  59. figure
  60. montage(reshape(imageProcBin, s(1), s(2), 1, s(3)));
  61.  
  62. % 4.a)
  63. imageProcBin = smooth3(imageProcBin);
  64. % 4.b)
  65. idx = find(imageProcBin > 120);
  66. imageProcBin(ind2sub(s, idx)) = 255;
  67.  
  68. % 5.a)
  69. CC = bwconncomp(imageProcBin, 26);
  70. % 5.b)
  71. maxCompId = 1;
  72. maxCompSize = numel( CC.PixelIdxList{maxCompId} );
  73. for id = 2 : CC.NumObjects
  74.     if numel( CC.PixelIdxList{id} ) > maxCompSize
  75.         maxCompSize = numel( CC.PixelIdxList{id} );
  76.         maxCompId = id;
  77.     end
  78. end
  79. posBoneStructure = CC.PixelIdxList{maxCompId};
  80. % 5.c)
  81. imageProcBin = zeros(s(1), s(2), 1, s(3), 'uint8');
  82. imageProcBin(posBoneStructure) = 255;
  83.  
  84.  
  85. %% Surface-Rendering der Knochenstruktur
  86. % 1.
  87. SFimageProcBin = isosurface(imageProcBin, 100);
  88. SFimageVolumeBin = isosurface(imageVolumeBin, 100);
  89.  
  90. % 3.a)
  91. imageVolume = smooth3(imageVolume);
  92.  
  93. % 2.
  94. figure;
  95. patchedVolume = patch(SFimageVolumeBin, 'FaceColor', 'blue', 'EdgeColor', 'none');
  96. % 3.b)
  97. isonormals(imageVolume, patchedVolume);
  98. % 3.c)
  99. view(3);
  100. lighting phong;
  101. camlight;
  102. camlight(80, -150);
  103. daspect([1 1 0.56]);
  104.  
  105. % 2.
  106. figure;
  107. patchedProc = patch(SFimageProcBin, 'FaceColor', 'blue', 'EdgeColor', 'none');
  108. % 3.b)
  109. isonormals(imageVolume, patchedProc);
  110. % 3.c)
  111. view(3);
  112. lighting phong;
  113. camlight;
  114. camlight(80, -150);
  115. daspect([1 1 0.5]);
  116.  
  117. % 4. Die Stufen sind zwar immer noch vorhanden, aber es sind erkennbar
  118. % weniger.
Advertisement
Add Comment
Please, Sign In to add comment