UOMOP

Feasibility for target PSNR 본문

DE/Graph

Feasibility for target PSNR

Happy PinGu 2024. 9. 4. 14:40
% MATLAB 코드 시작
plot_psnr_methods(512, 40)

function plot_psnr_methods(dim, snr)
    % 데이터 설정: 각 방법별 DIM과 SNR에 따른 데이터 구성
    data = {
        % Proposed 데이터
        'Proposed', 512, 40, [18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30], ...
                          [25.24, 25.28, 25.34, 25.49, 25.72, 26.03, 26.44, 26.90, 27.35, 27.76, 28.10, 28.36, 28.54];
        'Proposed', 512, 20, [18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30], ...
                          [23.97, 24.03, 24.15, 24.36, 24.64, 24.97, 25.29, 25.57, 25.75, 25.84, 25.88, 25.88, 25.87];
        'Proposed', 256, 40, [18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30], ...
                          [24.54, 24.58, 24.64, 24.77, 24.97, 25.25, 25.58, 25.94, 26.26, 26.52, 26.71, 26.83, 26.90];
        'Proposed', 256, 20, [18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30], ...
                          [23.43, 23.50, 23.61, 23.78, 24.01, 24.25, 24.48, 24.65, 24.74, 24.79, 24.80, 24.80, 24.79];
        % Random 데이터
        'Random', 512, 40, [18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30], ...
                          [21.75, 22.04, 22.48, 23.08, 23.83, 24.63, 25.43, 26.24, 26.93, 27.48, 27.87, 28.12, 28.26];
        'Random', 512, 20, [18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30], ...
                          [21.27, 21.60, 22.07, 22.66, 23.32, 23.99, 24.58, 25.01, 25.29, 25.45, 25.55, 25.60, 25.63];
        'Random', 256, 40, [18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30], ...
                          [21.49, 21.76, 22.17, 22.75, 23.49, 24.29, 25.03, 25.65, 26.11, 26.41, 26.59, 26.69, 26.76];
        'Random', 256, 20, [18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30], ...
                          [21.06, 21.37, 21.84, 22.44, 23.08, 23.67, 24.11, 24.42, 24.59, 24.70, 24.75, 24.78, 24.79];
        % TopK 데이터
        'TopK', 512, 40, [18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30], ...
                          [22.32, 22.64, 23.10, 23.70, 24.40, 25.17, 25.96, 26.68, 27.31, 27.79, 28.11, 28.30, 28.41];
        'TopK', 512, 20, [18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30], ...
                          [21.82, 22.15, 22.63, 23.19, 23.79, 24.39, 24.94, 25.35, 25.59, 25.72, 25.76, 25.76, 25.75];
        'TopK', 256, 40, [18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30], ...
                          [21.99, 22.28, 22.70, 23.23, 23.83, 24.49, 25.12, 25.67, 26.10, 26.40, 26.58, 26.68, 26.74];
        'TopK', 256, 20, [18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30], ...
                          [21.50, 21.84, 22.29, 22.82, 23.36, 23.88, 24.29, 24.55, 24.69, 24.76, 24.78, 24.78, 24.78];
    };

    deepjscc_targetPSNR = [18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30];

    % DeepJSCC 데이터 설정
    if dim == 512 && snr == 40
        deepjscc_avgPSNR = repmat(30.021, 1, length(deepjscc_targetPSNR));
    elseif dim == 512 && snr == 20
        deepjscc_avgPSNR = repmat(26.817, 1, length(deepjscc_targetPSNR));
    elseif dim == 256 && snr == 40
        deepjscc_avgPSNR = repmat(26.848, 1, length(deepjscc_targetPSNR));
    elseif dim == 256 && snr == 20
        deepjscc_avgPSNR = repmat(24.905, 1, length(deepjscc_targetPSNR));
    else
        deepjscc_avgPSNR = repmat(30.021, 1, length(deepjscc_targetPSNR)); % 기본값으로 설정
    end

    % 초기화
    methods = {'Random', 'TopK', 'Proposed'}; % Proposed를 마지막으로 그리도록 순서 변경
    colors = {'g--d', 'b--s', 'r-*'}; % 각 방법에 대한 다른 라인 스타일

    figure;
    hold on;
    plot(deepjscc_targetPSNR, deepjscc_targetPSNR, 'm', 'LineWidth', 1.5, 'DisplayName', 'Target PSNR');
    
    % 데이터 필터링 및 그래프 그리기
    for i = 1:length(methods)
        method = methods{i};
        filteredData = data(strcmp(data(:,1), method) & cell2mat(data(:,2)) == dim & cell2mat(data(:,3)) == snr, 4:5);

        if ~isempty(filteredData)
            targetPSNR = filteredData{1, 1};
            avgPSNR = filteredData{1, 2};
            plot(targetPSNR, avgPSNR, colors{i}, 'LineWidth', 2, 'DisplayName', method, 'MarkerSize', 8);
        else
            disp(['해당 조건에 맞는 데이터가 없습니다: ', method]);
        end
    end

    % DeepJSCC 데이터 플로팅
    plot(deepjscc_targetPSNR, deepjscc_avgPSNR, 'k-.o', 'LineWidth', 2, 'DisplayName', 'DeepJSCC');

    % 보라색 직선 그리기 (Target PSNR 라인)
    ylimits = [0, 40]; % y축 범위 설정
    ylim(ylimits); % y축 설정 적용
    
    % dim에 따른 CR 값 설정
    if dim == 512
        cr_text = 'CR: 1/6';
    elseif dim == 256
        cr_text = 'CR: 1/12';
    else
        cr_text = sprintf('DIM: %d', dim); % 디폴트 경우
    end
    
    xlabel('Target PSNR (dB)');
    ylabel('Average PSNR (dB)');
    title(sprintf('Comparison of methods (%s, SNR: %ddB)', cr_text, snr));
    
    % 범례 위치 설정
    legend show;
    legend('Location', 'southeast');

    grid on;
    hold off;
end
% MATLAB 코드 끝

'DE > Graph' 카테고리의 다른 글

X: Target PSNR, Y: Outage probability  (2) 2024.09.05
X: FLOPs constraint, Y: Avg PSNR  (0) 2024.09.04
Random Activate layer  (0) 2024.09.03
TopK Activate layer  (0) 2024.09.03
CBS activated layer  (0) 2024.09.03
Comments