日期:2020-2-9
dudonet的结构如下
第一步要通过线性插值实现去金属伪影
代码如下:
clear; clc; close all
%% 建立原始图像并加入金属球
Img0=phantom('Modified Shepp-Logan',401);
vec = -200:200;
[xx,yy] = meshgrid(vec,-vec);
x1 = 30;y1 = 50;r1 = 80;
Img0((xx-x1).^2+(yy-y1).^2<=r1) = 2;
R0 = radon(Img0);
srcImg = iradon(R0,0:179);
figure;imshow(srcImg),title('原始图像');
%% 选定阈值进行分割,选择阈值为1.5
[srcImg_width,srcImg_height]=size(srcImg);
%建立2个区域,分别为:metalImg notMetalImg
metalImg = zeros(srcImg_width,srcImg_height);
notMetalImg = zeros(srcImg_width,srcImg_height);
thrshldVal = 1.5;
for w=1:srcImg_width
for h=1:srcImg_height
if(srcImg(w,h)<thrshldVal)
metalImg(w,h) = 0;
notMetalImg(w,h) = srcImg(w,h);
else
metalImg(w,h) = 255;
notMetalImg(w,h) = 0;
end
end
end
figure;imshow(metalImg);title('金属的阈值分割图像');
figure;imshow(notMetalImg);title('非金属的阈值分割图像');
%% 投影与反投影
%Radon变换的角度范围
radon_theta=0:179;
% 金属的Radon变换
R_metal=radon(metalImg,radon_theta);
figure,imshow(R_metal,[]),title('金属的Radon变换');
xlabel('\theta');
%非金属部分的Radon变换
R_notMetal=radon(notMetalImg,radon_theta);
figure,imshow(R_notMetal,[]),title('非金属部分的Radon变换');
xlabel('\theta');
%% 直接去除金属部分,会使图像留下间隙,间隙使用插值算法进行校正
% 对金属图像的Radon变换结果进行插值校正
[radon_width,radon_height]=size(R_metal);
%radon变换的结果是横向坐标是距离,纵坐标是角度
%metalPQBeta矩阵,存储金属的radon变换的边界
metalPQBeta = zeros(radon_width,radon_height);
%获取金属的Radon变换的边界
for h = 1:radon_height
for w = 2:radon_width-1
preIndex = w -1;
nextIndex = w + 1;
currPix = R_metal(w,h);
if(currPix > 0)
if((R_metal(nextIndex,h) > 0 && R_metal(preIndex,h) == 0) || (R_metal(nextIndex,h) == 0 && R_metal(preIndex,h) > 0))
metalPQBeta(w,h) = 100;
end
end
end
end
% 开始插值,非金属的radon变换线性插值替换金属的radon变换
R_LI = R_notMetal;
for h = 1:radon_height
upIndex = 0;
for w = 1:radon_width
if( metalPQBeta(w,h) == 100 && upIndex == 0)
upIndex = w;
elseif(metalPQBeta(w,h) == 100 && upIndex ~= 0)
g_pBeta = R_LI(upIndex,h);
g_qBeta = R_LI(w,h);
midPixValue = R_LI(round((upIndex + w)*0.5),h);
%线性内插
for k = upIndex:w
left_val = g_pBeta*(w - k)/(w - upIndex);
right_val = g_qBeta*(k - upIndex)/(w - upIndex);
R_LI(k,h) = left_val + right_val;
end
end
end
end
figure;imshow(R_LI,[]);title('线性插值后的结果')
%% 逆变换与加金属
%对新的图像进行Radon的逆变换,得到图
%由于图中此时缺少金属的信息,因此把原图中的金属部分加到图中
%得到最终的金属伪影校正图
%1.对非金属的radon的变换的插值校正结果进行反变换
NImg=iradon(R_LI,radon_theta);
figure;imshow(NImg,[]);title('插值校正后的图')
%金属信息补偿
maxValImg = max(max(NImg));
%粘图
newImg=imresize(NImg,[401,401]);
metalImg=imresize(metalImg,[401,401]);
for w = 1:401
for h = 1:401
if(metalImg(w,h) > 0)
newImg(w,h) = maxValImg;
end
end
end
figure;imshow(newImg,[]);title('final')
插值效果,实际上效果非常有限,金属伪影依旧是一个非常困难的问题