作者bubu19861213 (宅宇)
看板java
标题[问题] 如何把灰阶bmp图复制暂存起来做程式运算??
时间Sun Nov 8 03:19:46 2009
我是想要做灰阶bmp图的边缘侦测
以下是我的部分程式码
====================================
public void run(ImageProcessor ip) {
//将ip图先暂存到tempImage里面
ImageProcessor tempImage = ip;
int w = ip.getWidth();
int h = ip.getHeight();
//int[][][] arr = new int[2][2][3];
int up,down,left,right,temp1,temp2;
for(int y = 0;y<h;y++)
{
up = y-1;
down = y+1;
for(int x = 0;x<w;x++)
{
left = x-1;
right = x+1;
int total = 0;
temp1 = (int)((tempImage.getPixel(left,up))+0+0
+0-(tempImage.getPixel(x,y))+0
+0+0+0);
if(temp1<0)
temp1 = -temp1;
temp2 = (int)(0+(tempImage.getPixel(x,up))+0
-(tempImage.getPixel(left,y))+0+0
+0+0+0);
if(temp2<0)
temp2 = -temp2;
total = temp1+temp2;
if(total>256)
total = 256;
if(total<0)
total = 0;
ip.putPixel(x, y, total);
}
}
}
}
========================================
//将ip图先暂存到tempImage里面
ImageProcessor tempImage = ip;
这里好像有问题
请问要怎样把我读取到的ip图先复制一份放到tempImage里面
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 219.70.6.115
1F:推 PsMonkey:实在很想批个作业文条款,你的程式码跟你的问题根本就... 11/08 13:41
2F:推 smallworld:边缘侦测其实有现成的CONVOLUTION函式可用 11/08 14:11
3F:→ bubu19861213:後来我宣告阵列去存原图的Pixel值勒... 11/08 15:22
4F:→ bubu19861213:我之前用C++写过,最近刚学JAVA,学用JAVA写看看Orz 11/08 15:28