作者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
推 PsMonkey:實在很想批個作業文條款,你的程式碼跟你的問題根本就... 11/08 13:41
推 smallworld:邊緣偵測其實有現成的CONVOLUTION函式可用 11/08 14:11
→ bubu19861213:後來我宣告陣列去存原圖的Pixel值勒... 11/08 15:22
→ bubu19861213:我之前用C++寫過,最近剛學JAVA,學用JAVA寫看看Orz 11/08 15:28