rgb_to_png.m 1.08 KB
clear all

numFrame = 48;
width = 768;
height = 768;
sequence=["CrowdRun_768x768_50_8bit_444","DucksTakeOff_768x768_50_8bit_444",
    "OldTownCross_768x768_50_8bit_444","ParkJoy_768x768_50_8bit_444",
    "ArenaOfValor_768x768_60_8bit_444","GlassHalf_768x768_24_8bit_444"];
for i=6:6
    seq=sequence{i};
    % Target_folder = "ArenaOfValor_1920x1080_60_8bit_444.rgb";
    Target_folder=seq+".rgb";
    %---- setting ---- 

    fileID = fopen(Target_folder,'r');
    for f = 1:numFrame
        R8 = uint8(zeros(height,width));
        G8 = uint8(zeros(height,width));
        B8 = uint8(zeros(height,width));

        for j = 1:height
          R8(j,:) = fread(fileID,width); 
        end
        for j = 1:height
          G8(j,:) = fread(fileID,width); 
        end
        for j = 1:height
          B8(j,:) = fread(fileID,width); 
        end
        

        RGB(:,:,1) = im2double(R8);
        RGB(:,:,2) = im2double(G8);
        RGB(:,:,3) = im2double(B8);
        saveFileName = "GlassHalf\\"+seq + "_frame"+(f-1)+".png";
        imwrite(RGB,saveFileName);
    end
    fclose(fileID);
    
end