第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

調(diào)整大小過(guò)程中的 OpenImaj OutOfMemoryError

調(diào)整大小過(guò)程中的 OpenImaj OutOfMemoryError

楊__羊羊 2022-11-02 10:14:37
我有兩張照片,一張是放大的,第二張是大的廣角照片??紤]第一個(gè)圖像是第二個(gè)圖像的裁剪(盡管它不是)。我從每張照片中選擇一個(gè)像素,代表兩張照片中的相同事物(比如一個(gè)男人的鼻子)。我將第一張圖片以一定的透明度覆蓋在第二張圖片的頂部,對(duì)齊兩個(gè)選定的像素?現(xiàn)在我想縮放第二張圖像,直到第一張圖像基本上消失,因?yàn)榈诙垐D像的比例與第一張圖像的比例匹配。我正在使用 OpenImaj,并使用 MBFImage.overlayInPlace() 成功完成了這項(xiàng)工作。我遇到的問(wèn)題是,當(dāng)我使用 ResizeProcessor 縮放第二個(gè)圖像時(shí),如果我必須將第二個(gè)圖像縮放太多( >5x ),我會(huì)得到一個(gè)“OutOfMemoryError: Java Heap Space”。我已經(jīng)使用 JDK 12 64bit 將 -Xmx 提升到 12G。我嘗試了 ResizeProcessor、BilinearInterpolation 和 BicubicInterpolation 調(diào)整器,結(jié)果都一樣。這是我最近嘗試的方法。根據(jù)我給 JVM 的內(nèi)存量,它有時(shí)會(huì)在調(diào)整大小時(shí)失敗,有時(shí)會(huì)在 toRGB() 上失?。簆rivate MBFImage scaleImage2(float scaleFactor) throws IOException {    FImage img2Flat = image2.flatten();    int width = (int)Math.round(img2Flat.getWidth() * scaleFactor);    int height = (int)Math.round(img2Flat.getHeight() * scaleFactor);    BilinearInterpolation resizer = new BilinearInterpolation(width, height, 1/scaleFactor);    resizer.processImage(img2Flat);    return img2Flat.toRGB();}這是我疊加圖像的地方:private MBFImage createScaledOverlay() {    MBFImage scaledImg2 = null;    if(scaledLastCrop == null) {        try {            scaledLastCrop = scaleLastCrop();        } catch (IOException e) {            e.printStackTrace();        }    }    try {        scaledImg2 = scaleImage2(image2ScaleFactor);    } catch (IOException e) {        e.printStackTrace();    }    int img2ScaledPixelx = Math.round(image2SelectedPixel.x * image2ScaleFactor);    int img2ScaledPixely = Math.round(image2SelectedPixel.y * image2ScaleFactor);    int lastCropScaledPixelx = (int)Math.round(lastCropSelectedPixel.x * lastCropScaleFactor);    int lastCropScaledPixely = (int)Math.round(lastCropSelectedPixel.y * lastCropScaleFactor);    scaledImg2.overlayInplace(scaledLastCrop, img2ScaledPixelx - lastCropScaledPixelx, img2ScaledPixely - lastCropScaledPixely);    return scaledImg2;}我可以選擇兩條前進(jìn)的道路之一:修復(fù) OutOfMemoryError疊加兩個(gè)圖像的另一種方法
查看完整描述

1 回答

?
慕村225694

TA貢獻(xiàn)1880條經(jīng)驗(yàn) 獲得超4個(gè)贊

有時(shí)一個(gè)解決方案是如此明顯以至于令人尷尬。

現(xiàn)在想想,我真正的目標(biāo)是找到兩個(gè)圖像之間的比例因子。我可以縮小 image1,而不是放大 image2。這要少得多的內(nèi)存密集型。然后關(guān)于 image2 我可以反轉(zhuǎn)這個(gè)比例因子。


查看完整回答
反對(duì) 回復(fù) 2022-11-02
  • 1 回答
  • 0 關(guān)注
  • 116 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)