日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

java图像处理之图像融合

發(fā)布時(shí)間:2024/1/23 编程问答 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java图像处理之图像融合 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

? ? ? ? 圖像融合,把像素大小相同,拍攝位置相同的照片通過一定方式進(jìn)行融合。下面介紹幾種簡(jiǎn)單的圖像融合方式。

? ? ? ? 1、通過對(duì)應(yīng)像素均值進(jìn)行融合。這種融合方式可用于處理亮度變換較大的圖片,由于相機(jī)測(cè)光和成像水平有限,對(duì)于成像范圍內(nèi)陰暗部分和明亮部分往往處理不好,要保證陰暗部分,則會(huì)導(dǎo)致明亮部分過曝;要保證明亮部分成像,則會(huì)導(dǎo)致陰暗部分太暗。對(duì)于這種情況,一種是采用較低的曝光參數(shù)保證明亮部分不過曝,通過調(diào)整亮度顯示出陰影部分,再通過均值合并生成圖像。第二種方法是通過相機(jī)拍攝,相機(jī)采用三腳架固定位置,用不同曝光參數(shù)進(jìn)行拍攝,拍攝完成后將幾張影像進(jìn)行均值合并。

? ? ? ? 另外,某些“鬼影”照片其實(shí)也是用類似方式合成的。

? ? ? ? 代碼:

public BufferedImage imageCombineByAverage(List<BufferedImage> images) { BufferedImage tempImage = new BufferedImage(images.get(0).getWidth(), images.get(0).getHeight(), images.get(0).getType());for(int i = 0; i < images.get(0).getWidth(); i++) {for(int j = 0; j < images.get(0).getHeight(); j++) {int R = 0,G = 0,B = 0;for(BufferedImage image : images) {int rgb = image.getRGB(i, j);int r = (rgb >> 16) & 0xff;int g = (rgb >> 8) & 0xff;int b = rgb & 0xff;R += r;G += g;B += b;}int aveR = R / images.size();int aveG = G / images.size();int aveB = B / images.size();int RGB = (255 & 0xff) << 24 | (clamp(aveR) & 0xff) << 16 | (clamp(aveG) & 0xff) << 8 | clamp(aveB) & 0xff;tempImage.setRGB(i, j, RGB);}} return tempImage;}

? ? ? ? 2、通過對(duì)應(yīng)像素值求和。適用于亮度很暗的場(chǎng)景,由于在亮度很低的場(chǎng)景下,采用高ISO可能會(huì)產(chǎn)生很多噪點(diǎn),可以通過較低的曝光參數(shù),固定相機(jī)位置,采用多次拍攝,對(duì)多張照片進(jìn)行對(duì)應(yīng)位置像素值求和的方式提高亮度和畫質(zhì)。

? ? ? ? 另外也可以用于對(duì)影像進(jìn)行特征提取或邊緣提取后,將處理后的特征點(diǎn)、線圖像與原圖進(jìn)行合并。

public BufferedImage imageCombineByAddAll(List<BufferedImage> images) { BufferedImage tempImage = new BufferedImage(images.get(0).getWidth(), images.get(0).getHeight(), images.get(0).getType());for(int i = 0; i < images.get(0).getWidth(); i++) {for(int j = 0; j < images.get(0).getHeight(); j++) {int R = 0,G = 0,B = 0;for(BufferedImage image : images) {int rgb = image.getRGB(i, j);int r = (rgb >> 16) & 0xff;int g = (rgb >> 8) & 0xff;int b = rgb & 0xff;R += r;G += g;B += b;}int RGB = (255 & 0xff) << 24 | (clamp(R) & 0xff) << 16 | (clamp(G) & 0xff) << 8 | clamp(B) & 0xff;tempImage.setRGB(i, j, RGB);}} return tempImage;}

? ? ? ? 3、最低值合并。

public BufferedImage imageCombineByMin(List<BufferedImage> images) { BufferedImage tempImage = new BufferedImage(images.get(0).getWidth(), images.get(0).getHeight(), images.get(0).getType());for(int i = 0; i < images.get(0).getWidth(); i++) {for(int j = 0; j < images.get(0).getHeight(); j++) {List<Integer> rList = new ArrayList<>();List<Integer> gList = new ArrayList<>();List<Integer> bList = new ArrayList<>();for(BufferedImage image : images) {int rgb = image.getRGB(i, j);int r = (rgb >> 16) & 0xff;int g = (rgb >> 8) & 0xff;int b = rgb & 0xff;rList.add(r);gList.add(g);bList.add(b);}Collections.sort(rList);Collections.sort(gList);Collections.sort(bList);int minR = rList.get(0);int minG = gList.get(0);int minB = bList.get(0);int RGB = (255 & 0xff) << 24 | (clamp(minR) & 0xff) << 16 | (clamp(minG) & 0xff) << 8 | clamp(minB) & 0xff;tempImage.setRGB(i, j, RGB);}} return tempImage;}

?

總結(jié)

以上是生活随笔為你收集整理的java图像处理之图像融合的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。