本人JAVA刚入门,希望能够编个小软件进行图片切割。例如,将数学试卷扫描后,按照题号将试卷进行切割,最终将切割完的部分保存。现在找了很多图形学 的书,似乎都没有什么大的进展,不知道该怎样处理,希望大家可以帮帮忙,并解答详细些。谢谢

解决方案 »

  1.   

    按照题号将试卷进行切割这是图象识别的问题吧?跟java不相干的,你用C++的话也会有同样问题啊。
    建议看图象识别的书,或找相关网站咨询,我估计这里会的人可能不会很多。
      

  2.   

    Raster java.awt.image.BufferedImage.getData(Rectangle rect)    /** 
         * Computes and returns an arbitrary region of the 
         * <code>BufferedImage</code>.  The <code>Raster</code> returned is a
         * copy of the image data and is not updated if the image is
         * changed.
         * @param rect the region of the <code>BufferedImage</code> to be
         * returned.
         * @return a <code>Raster</code> that is a copy of the image data of
         *          the specified region of the <code>BufferedImage</code> 
         * @see #setData(Raster)
         */
      

  3.   

    relive,你的答案是什么呀?我不太明白。能不能说得具体些?谢谢
      

  4.   

    import java.awt.Rectangle;
    import java.awt.image.BufferedImage;
    import java.io.File;
    import java.io.IOException;import javax.imageio.ImageIO;public class ImageTest
    { public static void main(String[] args)
    {
    try {
    BufferedImage image = ImageIO.read(new File("test.jpg"));
    saveSubImage(image, new Rectangle(10, 10, 100, 100), new File("sub1.jpg"));
    saveSubImage(image, new Rectangle(150, 150, 200, 300), new File("sub2.png"));
    saveSubImage(image, new Rectangle(20, 50, 70, 30), new File("sub3.bmp"));
    } catch (IOException e) {
    e.printStackTrace();
    return;
    }
    } private static void saveSubImage(BufferedImage image, 
    Rectangle subImageBounds, File subImageFile) throws IOException {
    if (subImageBounds.x <= 0 || subImageBounds.y <= 0 ||
    subImageBounds.x + subImageBounds.width >= image.getWidth() ||
    subImageBounds.y + subImageBounds.height >= image.getHeight()) {
    System.out.println("Bad subimage bounds");
    return;
    }

    BufferedImage subImage = image.getSubimage(
    subImageBounds.x, subImageBounds.y, 
    subImageBounds.width, subImageBounds.height);
    String fileName = subImageFile.getName();
    String formatName = fileName.substring(fileName.lastIndexOf('.') + 1); ImageIO.write(subImage, formatName, subImageFile);
    }
    }
      

  5.   

    谢谢relieve的热心帮助
    更要多谢gtlang78()
    我的问题解决了。
    作为菜鸟的我,你们的指点无疑给我增添了很多信心。呵呵