Kode berikut menggunakan Java untuk membagi gambar menjadi beberapa bagian.
Salinan kode adalah sebagai berikut:
SegmentationImage kelas publik {
Segmentasi Ikon Statis Publik (String ImageName, Int Width, Int Height, Int Height, Int Width) melempar Exception {
// Bersiaplah untuk membagi gambar
BufferedImage img1 = ImageIO.read (file baru (ImageName));
int half_w = img1.getWidth ();
int rGB [] = int baru [setengah_w*img1.getHeight ()];
img1.getrgb (0, 0, setengah_w, img1.getHeight (), rgb, 0, setengah_w);
BufferedImage img_half = BufferedImage baru (Half_W, img1.getHeight (), bufferedImage.type_int_argb);
img_half.setrgb (lebar, tinggi, tinggi, img1.getheight (), rgb, lebar, setengah_w);
Ikon returnicon = ImageIcon baru (img_half);
Return Returnicon;
}
}