主要思路:在旋转和平移操作之前进行一个~image操作,旋转和平移之后在~image(取反)回来就行。
img = imread('1.bmp');
img = rgb2gray(img);
thresh = graythresh(img); % 自动确定二值化阈值
img = imbinarize(img,thresh); % 对图像二值化
temp = imrotate(~img, 30 ); % 旋转30度
temp = ~temp;