Img=imread('8.jpg')
thresh = graythresh(Img); %自动确定二值化阈值
bwImg = im2bw(Img,thresh); %对图像二值化
[cut_m,cut_n] = size(Img);
cut_sumCol = sum(Img,1);
cut_sumRow = sum(Img,2);
%左右切割
minDigitWidth = 5;
maxDigitWidth = 25;
minColArea = 250;
col_intevl = 1;
offset = 1;
col_seg = findValleys(cut_sumCol, col_intevl, offset,minDigitWidth, maxDigitWidth);
col_seg= clean(col_seg,minDigitWidth);
result_seg_col = chooseBestSeg(col_seg,cut_sumCol,minColArea,7);
seg = result_seg_col;
%左右切割
minDigitWidth = 5;
maxDigitWidth = 25;
minColArea = 250;
col_intevl = 1;
offset = 1;
col_seg = findValleys(cut_sumCol, col_intevl, offset,minDigitWidth, maxDigitWidth);
col_seg=