Re: [請益] 影像處理問題

看板AndroidDev作者 (mamaya)時間13年前 (2011/05/08 18:14), 編輯推噓0(005)
留言5則, 3人參與, 最新討論串2/2 (看更多)
※ 引述《LEANSHC (LEANSHC)》之銘言: 以下是我直接看的 不確定這樣改有沒問題 : File file = new File("test.jpg"); : if (!file.exists()) { : JOptionPane.showMessageDialog(null, "File does not Exists!"); : System.exit(0); : } : try { : BufferedImage image = ImageIO.read(file); : final int width = image.getWidth(); : final int height = image.getHeight(); : BufferedImage leftsub =image.getSubimage(0, 0, width/2, height); : BufferedImage rightsub =image.getSubimage(width/2, 0, width/2, height); ^^^^^^^ 應該是width?? : int leftsubwidth=leftsub.getWidth(); : int leftsubheight=leftsub.getWidth(); : for (int y = 0; y < leftsubheight; y++) { : for (int x = 0; x < leftsubwidth; x++) { : leftsub.setRGB(x,y,leftsub.getRGB(x,y)&rightsub.getRGB(x,y)); : 小弟目前只想到說用&將兩張照片疊再一起 我對setRGB跟getRGB這東西沒什麼經驗 不過能作用的話 寫法可能是這樣 假設左右圖寬高相同 為picw,pich for(int x=0;x<picw;x++){ for(int y=0;y<pich;y++){ if((x+y)%2 == 0){ image.setRGB(x,y,leftsub.getRGB(x,y)); }else{ image.setRGB(x,y,rightsub.getRGB(x,y)); } } } 其盤格應該大致是這樣寫 如果要直或橫方像的交差排列 把判斷式的(x+y)改成 x或y就好 .....這應該算演算法問題= = -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 71.109.152.84

05/08 18:23, , 1F
幫了這一關, 下一關呢?
05/08 18:23, 1F

05/08 18:43, , 2F
問題只是語法熟悉度的話 給這種小code我覺得是還好
05/08 18:43, 2F

05/08 18:43, , 3F
不過我覺得這問題應該去java版問比較好
05/08 18:43, 3F

05/11 01:26, , 4F
不管怎樣mamaya大大 說的話都要好好C收..推~
05/11 01:26, 4F

05/11 15:04, , 5F
太抬舉我啦= ="
05/11 15:04, 5F
文章代碼(AID): #1DncqMwC (AndroidDev)
討論串 (同標題文章)
文章代碼(AID): #1DncqMwC (AndroidDev)