java 图片拼接 高分奉上

deathman_two 2008-03-30 03:57:10
package screen;
import java.io.File;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;

public class Picture
{ public Picture(String filePath,double leftcoordinate_x,int time){
try
{ for(int i=0;i<time;i++){
//读取第一张图片
File fileOne = new File(filePath+leftcoordinate_x+"("+i+")"+".Png");
BufferedImage ImageOne = ImageIO.read(fileOne);
int width = ImageOne.getWidth();//图片宽度
int height = ImageOne.getHeight();//图片高度
//从图片中读取RGB
int[] ImageArrayOne = new int[width*height];
ImageArrayOne = ImageOne.getRGB(0,0,width,height,ImageArrayOne,0,width);
//对第二张图片做相同的处理
int two=i+1;
File fileTwo = new File(filePath+leftcoordinate_x+"("+two+")"+".Png");
BufferedImage ImageTwo = ImageIO.read(fileTwo);
int[] ImageArrayTwo = new int[width*height];
ImageArrayTwo = ImageTwo.getRGB(0,0,width,height,ImageArrayTwo,0,width);
//对第三张图片做相同的处理
int three=i+2;
File fileThree = new File(filePath+leftcoordinate_x+"("+three+")"+".Png");
BufferedImage ImageThree = ImageIO.read(fileThree);
int[] ImageArrayThree = new int[width*height];
ImageArrayThree = ImageThree.getRGB(0,0,width,height,ImageArrayThree,0,width);
//生成新图片
int widthtwo=width+1240;
BufferedImage ImageNew = new BufferedImage(widthtwo,height,BufferedImage.TYPE_INT_RGB);
ImageNew.setRGB(0,0,width,height,ImageArrayOne,0,width);//设置左半部分的RGB
ImageNew.setRGB(623,0,width,height,ImageArrayTwo,0,width);//设置右半部分的RGB
ImageNew.setRGB(1240,0,width,height,ImageArrayThree,0,width);
File outFile = new File(filePath+leftcoordinate_x+"("+i+i+")"+".Png");
ImageIO.write(ImageNew, "png", outFile);//写图片
i=i+2;
}
}
catch(Exception e)
{
e.printStackTrace();
}
}

}
这是我用来图片拼接的,因为我把握不住那个起始X坐标所以拼接的横不理想,有没有高手能告诉下,有没有其它的方法,基于象素数组的算法,想做到无缝拼接!
或者油水能告诉我在GOOGLEEARTH上面按着方向键一秒钟,能在地图上走多少,我指的是相对于桌面的,也就是走了多少象素,有谁能相告一下,高分奉上,谢谢!
...全文
881 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
enendala 2012-08-12
  • 打赏
  • 举报
回复
这个方法效果很不好~图片质量会损坏
sunwei_07 2008-03-31
  • 打赏
  • 举报
回复
不知道先查出图片分辨率像素后再计算拼的像数位置行不行

帮顶了
tiyuzhongxin789 2008-03-31
  • 打赏
  • 举报
回复
我也想知道...
关注!!!
xlongbuilder 2008-03-31
  • 打赏
  • 举报
回复
帮顶
guofei_gf 2008-03-31
  • 打赏
  • 举报
回复
学习
deathman_two 2008-03-31
  • 打赏
  • 举报
回复
自己试了试,在googleearth下不同的高程,就是右下角的公里数(离地面的)一秒钟移动的像素尽然不一样,郁闷的要死,好像什么数组自相关能行,但不知道怎么做啊

62,623

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧