png_to_rgb.m
1.42 KB
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
clear all;
sequence=["CrowdRun","DucksTakeOff","OldTownCross","ParkJoy","ArenaOfValor","GlassHalf"];
resolution = {'2K','4K'};
QP=["1","2","3","4","5" ,"6"];
seq = sequence{2};
qp=QP{1};
resolution = resolution{1};
numFrame = 100;
Base_path="C:\Users\user\Documents\KHU\compressai\examples\\"+seq+"\\";
Target_folder =Base_path+"recon\\";
Save_folder = Base_path+"rgb\\";
%---- setting ----
for frame = 1:numFrame
% targetFileName = Target_folder +"recon"+(frame-1)+"_q"+qp+".png";
targetFileName = Target_folder +"recon"+(frame-1)+"_q"+qp+".png";
RGB = imread(targetFileName);
[height, width, color] = size(RGB);
R = RGB(:,:,1);
G = RGB(:,:,2);
B = RGB(:,:,3);
saveFileName = Save_folder + "recon"+(frame-1)+ ".rgb";
fileID = fopen(saveFileName,'w');
for j = 1:height
fwrite(fileID,R(j,:));
end
for j = 1:height
fwrite(fileID,G(j,:));
end
for j = 1:height
fwrite(fileID,B(j,:));
end
fclose(fileID);
end
size = 768 * 768 * 3;
% saveFileName = "C:\Users\user\Documents\KHU\Cap\compressai\examples\recon\\"+"recon"+"_q"+qp+ ".rgb";
saveFileName = "C:\Users\user\Documents\KHU\compressai\examples\recon\\"+seq+"_recon"+"_q"+qp+ ".rgb";
fout = fopen(saveFileName,'w');
for frame = 1:numFrame
targetFileName = Save_folder +"recon"+(frame-1)+".rgb";
RGB = fopen(targetFileName,'r');
fin = fread(RGB,size);
fclose(RGB);
fwrite(fout, fin);
end