Mid line through a set of dicom images in matlab -
i have set of dicom images on matlab , add midline going through images outputting images via imshow3d function
thanks
edit: here's have, random points not in middle run through image
>> clc; >>clear; >>%imports dicom images >>run dicomimport.m; >>%random points shortest distance test >>a = [1 10 200]; >>b = [500 512 300]; >>ab = b - a; >>n = max(abs(ab)) + 1; >>s = repmat(linspace(0, 1, n)', 1, 3); >>for d = 1:3 >> s(:, d) = s(:, d) * ab(d) + a(d); >>end >>s = round(s); >>z = 593; >>n = 512; >>x = zeros(n, n, z); >>x(sub2ind(size(x), s(:, 1), s(:, 2), s(:, 3))) = 1; >>c = find(x); >>ans.img(c) = 5000; >> %shows image >>imshow3d(ans.img);
so looks ans.img
contains 3d matrix consisting of image stack. looks you've got going, allow me bit differently. basically, need generate set of coordinates can access image stack , draw vertical line in middle of each image in image stack. this. first dimensions of stack, determine halfway point columns. next, generate set of coordinates draw line down middle 1 image. after this, repeat rest of slices , column major indices these:
%// dimensions [rows,cols,slices] = size(ans.img); %// halfway point columns col_half = floor(cols/2); %// generate coordinates vertical line 1 slice coords_middle_row = (1:rows).'; coords_middle_col = repmat(col_half, rows, 1); %// generate column major indices rest of slices: ind = sub2ind(size(ans.img), repmat(coords_middle_row, slices, 1), ... repmat(coords_middle_col, slices, 1), ... reshape(kron(1:slices, ones(rows, 1)), [], 1)); %// set pixels accordingly ans.img(ind) = 5000;
Comments
Post a Comment