public List<Double[]> split(String name, int row, int col) throws IOException {
		File file = new File(name); 
        FileInputStream fis = new FileInputStream(file);  
        image = ImageIO.read(fis); //reading the image file
        List<Double[]> list = new ArrayList<Double[]> ();
        rows = row; 
        cols = col;  
        chunks = rows * cols;  
  
        chunkWidth = image.getWidth() / cols; // determines the chunk width and height  
        chunkHeight = image.getHeight() / rows;  

        int count = 0;  
        BufferedImage imgs[] = new BufferedImage[chunks]; //Image array to hold image chunks  
        for (int x = 0; x < rows; x++) {  
            for (int y = 0; y < cols; y++) {  
                //Initialize the image array with image chunks  
                imgs[count] = new BufferedImage(chunkWidth, chunkHeight, image.getType());  
  
                // draws the image chunk  
                Graphics2D gr = imgs[count++].createGraphics();  
                gr.drawImage(image, 0, 0, chunkWidth, chunkHeight, chunkWidth * y, chunkHeight * x, chunkWidth * y + chunkWidth, chunkHeight * x + chunkHeight, null);  
                gr.dispose();  
                Double[] pos = {(double)chunkWidth * ((double)(y) + 0.5), (double)chunkHeight * ((double)(x) + 0.5)};
                list.add(pos);
            }  
        }  
        System.out.println("Splitting done");  
      //writing mini images into image files  
        for (int i = 0; i < imgs.length; i++) {  
            ImageIO.write(imgs[i], "jpg", new File("/Users/xwang/Documents/workspace/SLDA/imagesplit/" + name.substring(name.length() - 7) + i + ".jpg"));  
        }  
        System.out.println("Mini images created"); 
        return list;
	}