記錄下來,避免重複勞動,同時幫助像我一樣需要幫助的人
clc;clear;close all
%% 寫圖像
img = imread('1.bmp');
fileID1=fopen('test.bin','w');
A = rgb2gray(img);
fwrite(fileID1,A');
fclose(fileID1);
%% 讀圖像
fileID2=fopen('test.bin','r');
B=fread(fileID2);
fclose(fileID2);
B = uint8(reshape(B,1024,768))';
%% 繪圖
figure
subplot(1,2,1)
imshow(A)
subplot(1,2,2)
imshow(B)
%%