How do I display 55x305x4 .mat file as an image in Matlab and save it ?

1 回表示 (過去 30 日間)
saddam abdulwahab
saddam abdulwahab 2018 年 6 月 7 日
コメント済み: Saddam Abdulwahab 2018 年 6 月 7 日
welcome All Matlab users, I have an depth image in .mat file the image 4 channel 55*305*4 ... I have a problem with display it and save it in External file.please,could you help me.
  6 件のコメント
sloppydisk
sloppydisk 2018 年 6 月 7 日
You must really specify what the input channels represent otherwise there is no meaningful way of converting the file and we will just be guessing at what you want.
Saddam Abdulwahab
Saddam Abdulwahab 2018 年 6 月 7 日
I have this file s.mat I need save it as depth image like this image depth.png

サインインしてコメントする。

回答 (1 件)

Anton Semechko
Anton Semechko 2018 年 6 月 7 日
% Data array
A=Position3DGrid;
% Convert to uint8
I_min=min(A(:));
I_max=max(A(:));
A=uint8(255*(A-I_min)/(I_max-I_min));
% Composite image
n=2; % number of pixels added to when making a boundary between channels; to separate them visually
IM=cell(4,1);
for i=1:4
im=repmat(A(:,:,i),[1 1 3]);
if i<4 % boundary
im=padarray(im,[n 0 0],255,'post');
end
IM{i}=im;
end
IM=cell2mat(IM);
IM=padarray(IM,[n n 0],255);
% Save composite image to current directory
imwrite(IM,'composite image.jpg')
% This is what the composite image looks like
figure, imshow(IM)

カテゴリ

Help Center および File ExchangeImport, Export, and Conversion についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by