9. matlab图像处理基础——JPEG压缩+类型转换

1、JPEG压缩

  imwrite(原始图像,目标图像,'quality',比率)

  比率:[0, 100]  值越小,压缩比率越大

%% JPEG压缩
I = imread('cameraman.tif');
% imshow(I);
imwrite(I,'test.jpg','quality',10);
J = imread('test.jpg');
subplot(1,2,1),imshow(I);
subplot(1,2,2),imshow(J);

2、类型转换

(1)RGB转灰度

  灰度图像 = rgb2gray(RGB图像)

%% RGB转灰度
I = imread('coloredChips.png');
subplot(1,2,1),imshow(I);
J = rgb2gray(I);
subplot(1,2,2),imshow(J);

(2)灰度图像二值化

  二值图像 = imbinarize(灰度图像)

%% 灰度图像二值化
I = imread('cameraman.tif');
subplot(1,2,1),imshow(I);
J = imbinarize(I);
subplot(1,2,2),imshow(J);

posted @ 2020-05-13 00:01  红叶楠木  阅读(1720)  评论(0编辑  收藏  举报