clc, clear, close all % Read the raw image data into a vector fid = fopen('image.rgb', 'r'); data = fread(fid, inf, 'uint16'); fclose(fid); % Reshape the data into an M-by-N matrixb M = 240; % Image height N = 240; % Image width data = swapbytes(uint16(reshape(data, [N M])')); % Convert the RGB565 data to RGB888 format r = uint8(bitshift(bitand(data, 0xF800), -8)); g = uint8(bitshift(bitand(data, 0x07E0), -3)); b = uint8(bitshift(bitand(data, 0x001F), 3)); rgb = cat(3, r, g, b); % Display the image size(rgb) imshow(rgb);