본문 바로가기

카테고리 없음

USTB 스터디 4: 정량적으로 성능 평가하기

여러가지 파라미터로 출력은 했지만 이게 얼마나 '좋은 성능'의 값인지 눈으로 만 봐서는 알 수가 없다.

 

그래서 CNR과 PSNR을 직접 계산해 보려고 한다.

CNR(Contrast-to-Noise Ratio) 대조도 대 잡음비

PSNR(Peak Signal-to-Noise Ratio) 최대 신호 대 잡음비 

 

 

CNR

μ: 각 영역의 평균 밝기

σ: 각 영역의 표준 편차

 

CNR이 높을수록 배경과 타겟이 뚜렷하게 대비되어 보인다.

PSNR

원래는 영상 압축이나 복원 성능을 측정하는 지표이지만

MAX(I) = 영상의 최대 밝기값

MSE: 원본 영상과 비교영상 사이의 평균 제곱 오차

초음파에서 원본 대비 노이즈가 얼마나 섞여있는지 측정하는 척도가 될수있다.

 

 

PICMUS 데이터셋의 표준 ROI(관심영역) 좌표는 논문에 기제되어있다.

 

%% PICMUS Tukey window 비교 실험
% CNR / gCNR 계산

clear
clc

%% 데이터 다운로드

url='http://ustb.no/datasets/';
filename='PICMUS_experiment_contrast_speckle.uff';

tools.download(filename, url, data_path);

%% 데이터 로드

channel_data = uff.read_object([data_path filesep filename],'/channel_data');
scan         = uff.read_object([data_path filesep filename],'/scan');

%% Beamforming pipeline 설정

pipe = pipeline();
pipe.channel_data = channel_data;
pipe.scan         = scan;

pipe.receive_apodization.f_number = 1.7;
pipe.transmit_apodization.f_number = 1.7;

pipe.transmit_apodization.window = uff.window.tukey50;

%% 비교할 Tukey window

windows = {uff.window.tukey25, uff.window.tukey50, uff.window.tukey75};
names   = ["Tukey25","Tukey50","Tukey75"];

CNR_values  = zeros(length(windows),1);
gCNR_values = zeros(length(windows),1);

%% ROI 설정 -> 출처: 데이터 셋

cyst_center_x = 0e-3;
cyst_center_z = 15e-3;
radius        = 2e-3;

bg_center_x = 8e-3;
bg_center_z = 15e-3;

%% Tukey window loop

for k = 1:length(windows)

    pipe.receive_apodization.window = windows{k};

    %% Beamforming

    b = pipe.go({midprocess.das postprocess.coherent_compounding});

    %% envelope

    env = abs(b.data);

    %% scan 좌표

    scp = b.scan;

    %% ROI mask

    cyst_mask = ((scp.x - cyst_center_x).^2 + (scp.z - cyst_center_z).^2) < radius^2;
    bg_mask   = ((scp.x - bg_center_x).^2   + (scp.z - bg_center_z).^2)   < radius^2;

    %% pixel 추출

    target_pixels = env(cyst_mask);
    bg_pixels     = env(bg_mask);

    %% -------------------
    %% CNR 계산
    %% -------------------

    mu_t = mean(target_pixels);
    mu_b = mean(bg_pixels);

    var_t = var(target_pixels);
    var_b = var(bg_pixels);

    CNR_values(k) = abs(mu_t-mu_b) / sqrt(var_t + var_b);

    %% -------------------
    %% gCNR 계산
    %% -------------------

    nbins = 100;

    [pt,edges] = histcounts(target_pixels,nbins,'Normalization','probability');
    [pb,~]     = histcounts(bg_pixels,edges,'Normalization','probability');

    overlap = sum(min(pt,pb));

    gCNR_values(k) = 1 - overlap;

    %% 이미지 출력

%    figure
%    b.plot([],names(k))
end

%% 결과 출력

results = table(names',CNR_values,gCNR_values);
disp(results)