100分求:关于JAVA图片切割的问题
本人JAVA刚入门,希望能够编个小软件进行图片切割。例如,将数学试卷扫描后,按照题号将试卷进行切割,最终将切割完的部分保存。现在找了很多图形学 的书,似乎都没有什么大的进展,不知道该怎样处理,希望大家可以帮帮忙,并解答详细些。谢谢 问题点数:100、回复次数:9Top
1 楼brightest()回复于 2005-04-14 22:43:02 得分 0
难到没有人可以解答我的问题么?真的是很着急呀。大家帮帮忙吧。谢谢Top
2 楼relive(六道轮回,无想转生)回复于 2005-04-15 10:19:15 得分 30
按照题号将试卷进行切割
这是图象识别的问题吧?跟java不相干的,你用C++的话也会有同样问题啊。
建议看图象识别的书,或找相关网站咨询,我估计这里会的人可能不会很多。Top
3 楼brightest()回复于 2005-04-15 21:46:45 得分 0
非常感谢你。我现在想干脆根据坐标来切割好了。根本不考虑图象识别的问题。我看了很多图象的书,觉得那样比较麻烦。主要是马上要交作品了。很急。请问该怎么做呢?谢谢Top
4 楼relive(六道轮回,无想转生)回复于 2005-04-16 13:58:52 得分 0
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)
*/
Top
5 楼menghuanlang(梦幻狼)回复于 2005-04-18 13:53:15 得分 0
帮你UP一下Top
6 楼jofield(道士)回复于 2005-04-19 11:26:07 得分 0
太深了....Top
7 楼brightest()回复于 2005-04-19 21:00:20 得分 0
relive,你的答案是什么呀?我不太明白。能不能说得具体些?谢谢Top
8 楼gtlang78()回复于 2005-04-20 11:02:58 得分 70
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);
}
}
Top
9 楼brightest()回复于 2005-04-26 22:44:34 得分 0
谢谢relieve的热心帮助
更要多谢gtlang78()
我的问题解决了。
作为菜鸟的我,你们的指点无疑给我增添了很多信心。呵呵Top




