Converting my ct scan into a better isosurface

2 views (last 30 days)
Im generating an isosurface out of CT scan data and it looks bad. Pleas help.
%% Opens the image stack from CT data imstack
% Extract size info from metadata voxel_size=[info.PixelSpacing; info.SliceThickness]'
%% View image data %stack = flipdim(stack, 3); % Make data face forwards im = stack(:, :, 350); % Pick middle slice for viewing max_level = double(max(im(:))); imt = imtool(im, [0, max_level]);
%% Segment tissue % Isolate and Display brain mass stackTemp = stack(:, :, 350); % crop the portion above the ROI stackTemp(:,:,1:308) = 0; stackTemp(:,:,409:end) = 0; %crop portion below ROI
%% Threshold on relaxation times lb = 120; % lower threshold (ignore soft tissue and air)
% Use morphological operations and blob analysis to exclude non-brain tissue % Convert image to B/W and remove small blobs % Not %Note: IMOPEN is equivalent to erosion followed by dilation stackAdjust = stack; stackAdjust(stackAdjust <= lb) = 0; stackAdjust(:,:,1:308) = 0; stackAdjust(:,:,409:end) =0;
% convert to black and white bw = stackAdjust > 0; imfill(bw, 'holes');
imshow(bw(:,:,350)); drawnow; shg; %% % Find Blobs % % Identify blobs and display them for a single frame. L = bwlabeln(bw); stats = regionprops(L,'Area','Centroid');
LL = L(:,:,350) + 1; cmap = hsv(length(stats));cmap = [0 0 0;cmap]; LL = cmap(LL, :);LL = reshape(LL, [info.Height, info.Width, 3]); imshow(LL); drawnow; shg;
%% % Select Largest Blob % % Determine the largest blob and eliminate all other blobs. A = [stats.Area]; biggest = find(A == max(A)); stackAdjust(L ~= biggest) = 0;
imA = imadjust(stackAdjust(:, :, 350)); imshow(imA); drawnow; shg;
%% level = thresh_tool(uint16(stackAdjust(:,:,350)), 'gray'); %% Create a 3-D display % Create a 3 dimensional display of the ROI tmp = text(128,200,'RENDERING 3D: Please wait','color','r','fontsize',14,... 'horizontalalignment','center'); drawnow; shg; % downsample Ds = smooth3(stackAdjust);
Ds = flipdim(Ds,1); Ds = flipdim(Ds,2); Ds = permute(Ds,[3 2 1]); voxel_size2 = voxel_size([1 3 2]).*[4 1 4];
bone_surface = isosurface(Ds,2.5);
h = figure('visible','off','outerposition',[0 0 800 600],'renderer','openGL'); patch(bone_surface,'FaceColor','g' ,'EdgeColor','none',... 'FaceAlpha',0.5);
view(45,15); daspect(1./voxel_size2); axis tight;axis off; camlight; camlight(-80,-10); lighting phong; delete(tmp);
movegui(h, 'center'); set(h,'visible','on');
%% Save isosurface as an .obj file vertface2obj(bone_surface.vertices,bone_surface.faces,'8916_tibia.obj');

Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!