[問題] 如何把灰階bmp圖複製暫存起來做程式運算??

看板java作者 (宅宇)時間16年前 (2009/11/08 03:19), 編輯推噓2(202)
留言4則, 3人參與, 最新討論串1/1
我是想要做灰階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
邊緣偵測其實有現成的CONVOLUTION函式可用
11/08 14:11, 2F

11/08 15:22, , 3F
後來我宣告陣列去存原圖的Pixel值勒...
11/08 15:22, 3F

11/08 15:28, , 4F
我之前用C++寫過,最近剛學JAVA,學用JAVA寫看看Orz
11/08 15:28, 4F
文章代碼(AID): #1AzSXL8g (java)