• 三维跨孔电磁波CT数据可视化框架搭建


    三维跨孔电磁波CT数据可视化框架搭建


    利用matlab实现对跨孔电磁波CT实测数据反演,并搭建了三维CT数据可视化框架,可装填实测CT反演数据。

    1、三维CT可视化结果

    对三维CT反演结果进行180°旋转,动态展示三维CT反演结果。

    三维CT动态图
    三维CT平面图
    在这里插入图片描述
    三维测线布置
    在这里插入图片描述
    CT数据解译结果。

    在这里插入图片描述

    2、matlab代码

    2.1、CT数据格式整理并保存

    close all
    clear
    clc
    
    [inFileName,PathName] = uigetfile('*.txt',...
        '选择CT数据文件','MultiSelect','on');
    
    filename = strcat(PathName,inFileName);
    
    % 将CT数据读取出来;
    data = importdata(filename);
    
    % 将每一层的数据提取出来,以第二列数据为标准(同一深度);
    x = data(:,2);
    % 找出每一层的起点;
    k = 1;
    n = length(x);
    for i = 2:n
        if x(i) ~= x(i-1)
            list(k) = i;
            k = k + 1;
        end
    end
    list(k) = n+1;
    list = [1,list];
    col = k;
    
    % 将深度记录下来
    np_depth = x(list(1:end-1));
    
    % 找出每一行的最大列数;
    row = max(data(:,1));
    row = ceil(row);
    % 一共有col行;
    
    Nper = zeros(col,row);
    % 将吸收系数值填充进Nper矩阵;
    % 注意吸收系数填充的位置,起点靠左还是靠右;
    np = data(:,3);
    y = data(:,1);
    for i = 1:length(list)-1
        begin = list(i);
        bend = list(i+1);
        len = bend - begin;
        np_o = np(begin:bend-1);
        np_y = y(begin);
        % 判断矩阵是在左边还是在右边;
        if np_y == 0
            Nper(i,1:len) = np_o;
        else
            Nper(i,end-len+1:end) = np_o;
        end
    end
    
    Nper = [np_depth,Nper];
    
    % 保存吸收系数及深度
    filename = strcat(inFileName(1:end-4),'.mat');
    save(filename,'Nper');
    
    contourf(Nper,30);colormap(jet);
    set(gca,'ydir','reverse');
    axis equal;
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63

    2.2、三维可视化

    close all
    clear 
    clc
    
    load('*.mat');
    np1 = Nper(:,2:end);
    np1_depth = Nper(:,1);
    clear Nper
    load('*.mat');
    np2 = Nper(:,2:end);
    np2_depth = Nper(:,1);
    clear Nper
    load('*.mat');
    np3 = Nper(:,2:end);
    np3_depth = Nper(:,1);
    
    
    % 将矩阵左右翻转;
    np1 = fliplr(np1);
    
    % np1(np1 == 0) = nan;
    % contourf(np1,100,'LineStyle','none');
    % colormap(jet);colorbar;
    % shading interp
    % caxis([0.1,0.7]);
    % set(gca,'ydir','reverse');
    % axis equal;
    
    clear np
    np = zeros(50,51);
    np(1:50,1:18) = np1;
    np(7:50,19:35) = np2;
    np(5:48,36:51) = np3;
    
    np(np == 0) = nan;
    contourf(np,80,'LineStyle','none');
    colormap(hsv);colorbar;
    set(get(colorbar,'title'),'string','视吸收系数[Nper/m]','fontsize',14);
    shading flat
    caxis([0,0.65]);
    set(gca,'ydir','reverse');
    xlabel('水平距离/m');
    ylabel('深度/m');
    axis equal;
    
    
    data_new = zeros(50,51,100);
    for i = 1:1000
        data_new(:,:,i) = np;
    end
    
    xslice = [10,40];
    yslice = [];
    zslice = 1:499:1000;
    slice(data_new,xslice,yslice,zslice);
    colormap('hsv');
    h = colorbar;
    set(get(h,'title'),'string','beta(Nper/m)');
    caxis([0,0.65]);
    colorbar('eastoutside');
    shading interp
    set(gca,'xticklabel',[]);
    set(gca,'yticklabel',[]);
    set(gca,'zticklabel',[]);
    % axis off
    alpha(0.8);
    view(345,-15);
    % 
    spinningGIF('zk45-48.gif');
    
    % el=-45;  %设置仰角为30度。
    % for az=0:1:1080  %让方位角从0变到360,绕z轴一周
    %     view(az,el);
    %     drawnow;
    % end
    
    % az= 345;   %设置方位角为0
    % for el=0:1:360*1000   %仰角从0变到360
    %     view(az,el);
    %     drawnow;
    % end
    
    % spinningGIF(fname): makes a spinning GIF of the current plot and saves it
    % Usage: make your 3D plot (using plot3(...) or scatter3(...) etc.) and
    % then call SpinningGIF with the file name that you want
    function spinningGIF(fname)
    %     axis off
    %     view(0,10)
        center = get(gca, 'CameraTarget');
        pos = get(gca, 'CameraPosition');
        radius = norm(center(1:2) - pos(1:2));
        angles = pi:0.02*pi:2*pi;
        for ii=1:length(angles)
           angle = angles(ii);
           set(gca, 'CameraPosition', [center(1) + radius * cos(angle),...
                                       center(2) + radius * sin(angle),...
                                       pos(3)]);
           drawnow;
           frame = getframe(1);
           im = frame2im(frame);
           [imind,cm] = rgb2ind(im,256);
           if ii == 1
               imwrite(imind,cm,fname,'gif', 'Loopcount',inf);
           else
               imwrite(imind,cm,fname,'gif','WriteMode','append','DelayTime', 0.25);
           end
        end
    end
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
  • 相关阅读:
    中央仓库更新失败,IDEA报错repository is non-nexus repo, or does not indexed
    k8s 读书笔记 - kubernetes 基本概念和术语(上)
    【C】想动态分配内存?动态内存管理了解一下
    python API自动化(Pytest+Excel+Allure完整框架集成+yaml入门+大量响应报文处理及加解密、签名处理)
    nvm安装及使用(mac)
    Codeforces Round 870 (Div. 2)C. Dreaming of Freedom(数论、约数)
    基于左序遍历的数据存储实践
    Vue 图片轮播第三方库 介绍
    Python之列表
    c++day4
  • 原文地址:https://blog.csdn.net/Neverlevsun/article/details/132674751