clc;close all;clear%Read Image% Rgbimga = Imread ('bmpinput_1080p.bmp'); Rgbimga= Imread ('bmpinput_720p.bmp'); RGBIMGB= rgbimga*0; Rgbimga=RGBIMGB; [Hs Vs Dim]=size (RGBIMGA); Gate= vs/6; %6 Vertical Color bar interval I=1; Rgbimga (:, (i-1) *gate+1: I*gate,1) =255; %Ri= i+1; Rgbimga (:, (i-1) *gate+1: I*gate,2) =255; %Gi= i+1; Rgbimga (:, (i-1) *gate+1: I*gate,3) =255; %Bi= i+1; Rgbimga (:, (i-1) *gate+1: I*gate,1) =255; %Ri= i+1; Rgbimga (:, (i-1) *gate+1: I*gate,2) =255; %Gi= i+1; Rgbimga (:, (i-1) *gate+1: I*gate,3) =255; %bfigure;imshow (RGBIMGA); [Hs Vs Dim]=size (RGBIMGB); Gate= hs/3; %3 horizontal color bar interval RGBIMGB (1: Gate,:,1) =255; %RRGBIMGB (Gate+1:2*gate,:,2) =255; %GRGBIMGB (2*gate+1:3*gate,:,3) =255; %bfigure;imshow (RGBIMGB); Rgbimga=uint8 (RGBIMGA); RGBIMGB=uint8 (RGBIMGB); Yuvima= RGB2YUV (RGBIMGA); %RGB2YCBCR% Yuvima =rgb2ycbcr (RGBIMGA); Figure;imshow (Uint8 (Yuvima)); Yuvimb=RGB2YUV (RGBIMGB); Figure;imshow (YUVIMB); Yuvimg=Yuvima;yuvimout= Zeros (1, Hs*vs*dim); %Organize Data yuvimout (1:3: Hs*vs*dim) = Reshape (Yuvimg (:,:,1)', 1,hs*vs); %%yYuvimout (2:3: Hs*vs*dim) = Reshape (Yuvimg (:,:,2)', 1,hs*vs); %%uYuvimout (3:3: Hs*vs*dim) = Reshape (Yuvimg (:,:,3)', 1,hs*vs); %%vFid= fopen ('IMGA_720P.YUV','WB'); %can be quickly output to file fwrite (Fid,yuvimout,'uint8'); fclose (FID); FID= fopen ('Imga_720p.txt','W'); fprintf (FID,'%02x\n', yuvimout); fclose (FID); Yuvimg=Yuvimb;yuvimout= Zeros (1, hs*vs*Dim); Yuvimout (1:3: Hs*vs*dim) = Reshape (Yuvimg (:,:,1)', 1,hs*vs);Yuvimout (2:3: Hs*vs*dim) = Reshape (Yuvimg (:,:,2)', 1,hs*vs);Yuvimout (3:3: Hs*vs*dim) = Reshape (Yuvimg (:,:,3)', 1,hs*vs);Fid= fopen ('IMGB_720P.YUV','WB'); Fwrite (Fid,yuvimout,'uint8'); fclose (FID); FID= fopen ('Imgb_720p.txt','W'); fprintf (FID,'%02x\n', yuvimout); fclose (FID);
Matlab code for generating color bars