YCBCR2RGB.m
% addpath(genpath(pwd)); %将当前文件夹下的所有文件夹都包括进调用函数的目录% clc,clear;function [ycbcr_img] = YCBCR2RGB(Y,Cb,Cr)[w,h] = size(Y);ycbcr_img = zeros(w,h,3);ycbcr_img(:,:,1) = Y+1.402*(Cr-128/255.0);ycbcr_img(:,:,2) = Y-0.344*(Cb-128/255.0)-0.714*(Cr-128/255.0);ycbcr_img(:,:,3) = Y+1.772*(Cb-128/255.0);end
RGB2YCBCR.m
% clc,clear;function [Y,Cb,Cr,img_ycbcr] = RGB2YCBCR(RGB_image)% RGB_image = im2double(imread('./MRI_SPECT/SPETCT/SPECT.png'));R = RGB_image(:,:,1);G = RGB_image(:,:,2);B = RGB_image(:,:,3);Y = 0.299 * R + 0.587 * G + 0.114 * B;Cb = -0.1687 * R - 0.3313 * G + 0.5 * B + 128/255.0;Cr = 0.5 * R - 0.4187 * G - 0.0813 * B + 128/255.0;[w,h,~] = size(RGB_image);img_ycbcr = zeros(w,h,3);img_ycbcr(:,:,1) = Y;img_ycbcr(:,:,2) = Cb;img_ycbcr(:,:,3) = Cr;end