MATLAB图像处理笔记[灰度、二值处理]

clear all;clc;
%{
clear:清除工作空间的所有变量 
close all:关闭所有的Figure窗口 
clc:清除命令窗口的内容,对工作环境中的全部变量无任何影响
%}

x = imread('image.jpg');
subplot(2,2,1)%划分2x2区域,在第一格显示
imshow(x)
y = rgb2gray(x);%变为灰度图像
subplot(2,2,2)
imshow(y)
z1 = im2bw(x,0.55);%二值化处理
subplot(2,2,3)
imshow(z1)
z2 = im2bw(x,0.95);
subplot(2,2,4)
imshow(z2)

imwrite(z1,'image1.jpg');%保存,格式任意

猜你喜欢

转载自blog.csdn.net/qq_38221114/article/details/88692301