我有一个冠状动脉图像,由271帧组成。我已将图像转换为矢状视图,并通过将其转换为二进制来找到动脉的内表面。在它之后我想将它转换回横向视图以获得矢状视图信息,但它给了我错误的结果我只想在横向视图中得到两个点,但它给了我整行。
以下是矢状视图中带边缘的图像
以下是我的内容
clear , clc
mri = uint8(zeros(512,512,271)); % preallocate 4-D array
for frame=1:271
[mri(:,:,frame),map] = imread('image.tif',frame);
end
for angle = 0:1:180
if angle == 0
Img(:,:,:) = mri(:,:,:);
else
Img(:,:,:) = imrotate(mri(:,:,:),angle,'bilinear','crop');
end
ImgSg = squeeze(permute(Img, [1 3 2]));
for slice = 1: 271
Image(:,:,:) = Img(:,:,slice);
xcentre = floor(size(Image, 2) / 2);
ycentre = floor(size(Image, 1) / 2);
sliceC =(xcentre+ycentre)/2;
sliceimage = squeeze(permute(Image(:, sliceC, :), [1 3 2]));
if slice == 1
image3D = sliceimage;
else
image3D = cat(2, image3D, sliceimage);
end
end
ImgSg1 = ImgSg;
image3D(226:286,1:271)=10;
% imshow(ImgSg(:,:,256));
[counts,x] = imhist(image3D,16);
T = otsuthresh(counts);
BW = imbinarize(image3D,T);
% imshow3D(BW);
[rows, columns, numberOfColorChannels] = size(BW);
middleRow = floor(rows/2);
topHalf = BW(1:middleRow, :,:);
bottomHalf = BW(1+middleRow:end, :,:);
filterImg = bwareaopen(bottomHalf,25);
output_img = zeros(size(bottomHalf));
for col = 1: size(bottomHalf,2)
first_nnz_row = find(filterImg(:,col),1,'first');
output_img(first_nnz_row:end,col) = 1;
end
filterImg = bwareaopen(topHalf,25);
output_img1 = zeros(size(topHalf));
for col = 1: size(topHalf,2)
first_nnz_row1 = find(filterImg(:,col),1,'last');
output_img1(1:first_nnz_row1,col) = 1;
end
fullImage = [output_img1; output_img];
fullImage=logical(1 - fullImage);
i2 = bwperim(fullImage,8);
im1 = i2;
other_images = ImgSg;
blend = 0.2;
mask1 = im1;
fused = other_images;
for slice = 1 : size(fused, 2)
this_slice = fused(:,:,slice);
this_slice(mask1)=double(this_slice(mask1))*blend+double(im1(mask1)*(1-blend));
% imshow(this_slice)
fused(:,:,slice) = this_slice;
end
imshow(fused(:,:,256));
% imshow3D(fullImage);
ImgSg = squeeze(permute(fused, [1 3 2]));
imshow3D(ImgSg)
end
这里我附上了我的代码,它首先读取了图像。在2d获得segittal视图并找到边缘,找到边缘后,我将其与原始矢状图像相结合。并将其转换回tansverse视图我想要这样的结果
下面是输出图像