美文网首页
【matlab】二维图像重建三维图像

【matlab】二维图像重建三维图像

作者: 小小杨树 | 来源:发表于2022-01-04 14:24 被阅读0次

    绘制圆心位置相同,内外半径相同的系列圆 ,图片尺寸为128128,类似于血管的圆管柱图像;
    绘制圆心位置不同,内外半径相同的系列圆,图片尺寸为128
    128,类似于血管的圆管柱图像;
    绘制圆心位置不同,内外半径不同的系列圆,图片尺寸为128*128,类似于血管的圆管柱图像;
    对图像进行插值处理
    对图像进行滤波平滑处理
    三维显示由系列圆重建的类血管三维图像

    clear all;
    close all;
    clc;
    h = 128;
    w = 128;
    r1 = 10;
    r2 = 12;
    Index = [1:80];
    nFrames = 80
    for i=1:80
    I = zeros(h, w);
    [x, y] = meshgrid(1:w, 1:h);
    a = ceil(w/2);
    b = ceil(h/2);
    I( r1^2 <=((x-a).^2 +(y-b).^2)) = 1;
    I(((x-a).^2 +(y-b).^2) <= r1^2 ) = 0.5;
    I(((x-a).^2 +(y-b).^2)>= r2^2 ) = 0;
    imwrite(I,['./1/',num2str(Index(i)),'.png']);
    end
    b = ceil(h/2)+ 0.00001* i * i * i;
    b = ceil(h/2)+ 5 * sin(pi * i /60);
    r1 = r1+0.01;
    r2 = r2+0.01;
    Box.x = 1;
    Box.y = 1;
    Box.w = 128;
    Box.h = 128;
    nFrames = 80;
    Image = zeros(Box.h,Box.w,nFrames);
    Index = [1:80];
    for i=1:nFrames
    filename = ['./1',num2str(Index(i)),'.png'];
    im = imread(filename);
    Image(:,:,i) = squeeze((im(Box.y:Box.y+Box.h-1,Box.x:Box.x+Box.w-1)));
    end
    [x,y,z] = size(Image);
    [hx,hy,hz] = meshgrid(1:y, 1:x, 1:z);
    hr = interp3(Image, hx, hy, hz, 'cubic');
    for i=1:y
    for j=1:x
    z_data = squeeze(hr(i,j,:));
    z_data_f = medfilt1(z_data,20);
    hr(i,j,:) = z_data_f;
    end
    end
    W = fspecial('average',[10,10]);
    for i=1:z
    imdata = squeeze(hr(:,:,i));
    imdata = imfilter(imdata,W,'replicate');
    hr(:,:,i) = imfilter(imdata,W,'replicate');
    end
    W = fspecial('gaussian',[10,10],1);
    for i=1:z
    imdata = squeeze(hr(:,:,i));
    imdata = imfilter(imdata,W,'symmetric');
    hr(:,:,i) = imfilter(imdata,W,'symmetric');
    end
    Image = smooth3(hr(:,:,1:1:end));
    fw=20;
    p=patch(isosurface(Image,fw))
    set(p,'facecolor','[0.75,0.1,0.2]','Edgecolor','none','FaceAlpha',1,'EdgeAlpha',0.5);
    isonormals(Image,p);
    p1=patch(isocaps(Image, fw));
    set(p1, 'FaceColor', 'red', 'EdgeColor', 'none','FaceAlpha',0.5,'EdgeAlpha',0);
    colorbar
    colormap('jet')
    daspect([1,1,0.5])
    view(3)
    lightangle(45,30);
    lighting gouraud
    p.AmbientStrength = 0.8;
    p1.SpecularColorReflectance = 0;
    p1.SpecularExponent = 50;
    
    

    相关文章

      网友评论

          本文标题:【matlab】二维图像重建三维图像

          本文链接:https://www.haomeiwen.com/subject/ogvqcrtx.html