????1.??????????
???????????????????????

????????????

???????????????????
????2.?????
????????????????????????????????????????
???????????????????????????????????????????????????????????????????????????????????????1?????????0??
????????????????????????????????1??????????У?????????????????1??У?????е??±???????????????????1???????±???????????????????е??????н???????????????
1 ????//?????
2     private java.util.List<BufferedImage> splitImage(BufferedImage originImg)
3             throws Exception {
4         java.util.List<BufferedImage> subImgList = new ArrayList<>();
5         int height = originImg.getHeight();
6         int[][] weight = getImgWeight(originImg);
7         int start = 0;
8         int end = 0;
9         boolean isStartReady = false;
10         boolean isEndReady = false;
11         for (int i = 0; i < weight.length; i++) {
12             boolean isBlank = isBlankArr(weight[i]);
13             if (isBlank) {
14                 if (isStartReady && !isEndReady) {
15                     end = i;
16                     isEndReady = true;
17                 }
18             } else {
19                 if (!isStartReady) {
20                     start = i;
21                     isStartReady = true;
22                 }
23             }
24             if (isStartReady && isEndReady) {
25                 subImgList.add(originImg.getSubimage(start?? 0?? end - start?? height));
26                 isStartReady = false;
27                 isEndReady = false;
28             }
29         }
30         return subImgList;
31     }
32
33     //??????????
34     private boolean isBlank(int colorInt) {
35         Color color = new Color(colorInt);
36         return color.getRed() + color.getGreen() + color.getBlue() > 600;
37     }
38
39     //?????????????
40     private boolean isBlankArr(int[] arr) {
41         boolean isBlank = true;
42         for (int value : arr) {
43             if (value == 0) {
44                 isBlank = false;
45                 break;
46             }
47         }
48         return isBlank;
49     }
50
51     //????????????
52     private int[][] getImgWeight(BufferedImage img) {
53         int width = img.getWidth();
54         int height = img.getHeight();
55         int[][] weight = new int[width][height];
56         for (int x = 0; x < width; ++x) {
57             for (int y = 0; y < height; ++y) {
58                 if (isBlank(img.getRGB(x?? y))) {
59                     weight[x][y] = 1;
60                 }
61             }
62         }
63         return weight;
64     }