Skip to content

Instantly share code, notes, and snippets.

@zhulianhua
Created June 6, 2018 13:50
Show Gist options
  • Save zhulianhua/5e07a0d794eedaab6bdfef3329379822 to your computer and use it in GitHub Desktop.
Save zhulianhua/5e07a0d794eedaab6bdfef3329379822 to your computer and use it in GitHub Desktop.
matlab 图像二进制化并保存为ASCII文件
IMG = imread('xxx.jpg'); % image data
L = im2bw(IMG); % image data to logical data
I = int8(L); % convert to 8 bit integer
dlmwrite('data.dat', I, ' ') % write ascii file, using space(' ') as delimeter
% open data.dat to view it
@zhulianhua
Copy link
Author

I = fliplr(I);
or
I = flipud(I);
or
I = rot90(I);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment