[問題] 如何把灰階bmp圖複製暫存起來做程式運算??
我是想要做灰階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
推
11/08 13:41, , 1F
11/08 13:41, 1F
推
11/08 14:11, , 2F
11/08 14:11, 2F
→
11/08 15:22, , 3F
11/08 15:22, 3F
→
11/08 15:28, , 4F
11/08 15:28, 4F