复制代码代码如下:
public class SegmentationImage{
public static Icon Segmentation(String imagename,int Width,int Height,int height,int width) throws Exception{
// 准备分割图片
BufferedImage img1=ImageIO.read(new File(imagename));
int half_w=img1.getWidth();
int rgb[]=new int[half_w*img1.getHeight()];
img1.getRGB(0, 0, half_w, img1.getHeight(), rgb, 0, half_w);
BufferedImage img_half=new BufferedImage(half_w, img1.getHeight(), BufferedImage.TYPE_INT_ARGB);
img_half.setRGB(Width,Height,height,img1.getHeight(), rgb,width,half_w);
Icon returnIcon = new ImageIcon(img_half);
return returnIcon;
}
}