Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Android中应用过滤器时,图像变得过于嘈杂_Android_Image_Bitmap_Lookup Tables - Fatal编程技术网

在Android中应用过滤器时,图像变得过于嘈杂

在Android中应用过滤器时,图像变得过于嘈杂,android,image,bitmap,lookup-tables,Android,Image,Bitmap,Lookup Tables,我正在开发一个应用程序,其中包括过滤器和作物太。这是我用的。在这里,我使用了8*8 LUT。这里我想裁剪过滤后的图像(8*8 lut) 下面是裁剪图像的逻辑 Bitmap cropbitmap = ivCropimageView.getCroppedImage(); 使用此位图,我生成一个缩略图位图,如下所示 Bitmap thumbImage = ThumbnailUtils.extractThumbnail(cropbitmap, 190, 250); 当我尝试为所有过滤器生成缩略图时,

我正在开发一个应用程序,其中包括过滤器和作物太。这是我用的。在这里,我使用了8*8 LUT。这里我想裁剪过滤后的图像(8*8 lut)

下面是裁剪图像的逻辑

Bitmap cropbitmap = ivCropimageView.getCroppedImage();
使用此位图,我生成一个缩略图位图,如下所示

Bitmap thumbImage = ThumbnailUtils.extractThumbnail(cropbitmap, 190, 250);
当我尝试为所有过滤器生成缩略图时,缩略图显示为太过类似噪音

这个结果是当我实现来自的答案时得到的


因此,如果有人有ab想法,请帮助我。

你可以完成这一过程,希望它能帮助你获得正确的流程

照片是这里的主要位图

mLut3D是存储在drawable中的LUT图像数组

    RenderScript mRs;
    Bitmap mLutBitmap, mBitmap;
    ScriptIntrinsic3DLUT mScriptlut;
    Bitmap mOutputBitmap;
    Allocation mAllocIn;
    Allocation mAllocOut;
    Allocation mAllocCube;
    int mFilter = 0;

mRs = RenderScript.create(yourActivity.this);
public Bitmap filterapply() {
        int redDim, greenDim, blueDim;
        int w, h;
        int[] lut;

        if (mScriptlut == null) {
            mScriptlut = ScriptIntrinsic3DLUT.create(mRs, Element.U8_4(mRs));
        }
         if (mBitmap == null) {
         mBitmap = photo;
}
        mOutputBitmap = Bitmap.createBitmap(mBitmap.getWidth(),
                mBitmap.getHeight(), mBitmap.getConfig());

        mAllocIn = Allocation.createFromBitmap(mRs, mBitmap);
        mAllocOut = Allocation.createFromBitmap(mRs, mOutputBitmap);
        // }

        mLutBitmap = BitmapFactory.decodeResource(getResources(),
                mLut3D[mFilter]);
        w = mLutBitmap.getWidth();
        h = mLutBitmap.getHeight();
        redDim = w / h;
        greenDim = redDim;
        blueDim = redDim;
        int[] pixels = new int[w * h];
        lut = new int[w * h];
        mLutBitmap.getPixels(pixels, 0, w, 0, 0, w, h);
        int i = 0;

        for (int r = 0; r < redDim; r++) {
            for (int g = 0; g < greenDim; g++) {
                int p = r + g * w;
                for (int b = 0; b < blueDim; b++) {
                    lut[i++] = pixels[p + b * h];
                }
            }
        }

        Type.Builder tb = new Type.Builder(mRs, Element.U8_4(mRs));
        tb.setX(redDim).setY(greenDim).setZ(blueDim);
        Type t = tb.create();
        mAllocCube = Allocation.createTyped(mRs, t);
        mAllocCube.copyFromUnchecked(lut);

        mScriptlut.setLUT(mAllocCube);
        mScriptlut.forEach(mAllocIn, mAllocOut);

        mAllocOut.copyTo(mOutputBitmap);
        return mOutputBitmap;
    }
renderscriptmrs;
位图mLutBitmap,mBitmap;
ScriptIntrinsic3DLUT mScriptlut;
位图输出位图;
分配mAllocIn;
分配mAllocOut;
分配方法;
int-mFilter=0;
mRs=RenderScript.create(yourActivity.this);
公共位图过滤器应用程序(){
int redDim、greenDim、blueDim;
int w,h;
int[]lut;
如果(mScriptlut==null){
mScriptlut=ScriptIntrinsic3DLUT.create(mRs,Element.U8_4(mRs));
}
if(mBitmap==null){
mBitmap=照片;
}
mOutputBitmap=Bitmap.createBitmap(mBitmap.getWidth(),
mBitmap.getHeight(),mBitmap.getConfig();
mAllocIn=Allocation.createFromBitmap(mRs,mBitmap);
mAllocOut=Allocation.createFromBitmap(mRs、mOutputBitmap);
// }
mLutBitmap=BitmapFactory.decodeResource(getResources(),
mLut3D[mFilter]);
w=mLutBitmap.getWidth();
h=mLutBitmap.getHeight();
redDim=w/h;
greenDim=redDim;
blueDim=redDim;
int[]像素=新的int[w*h];
lut=新整数[w*h];
获取像素(像素,0,w,0,0,w,h);
int i=0;
对于(int r=0;r
增加mFilter值以获得不同LUT图像的不同过滤效果,您可以查看它

你可以通过github上的this链接获得更多帮助,我从这里得到了答案:-


希望它能有所帮助

我正在开发一个LUT应用程序库,它可以简化Android中LUT图像的使用。现在它还可以猜测LUT的颜色轴:

它使用了我在文章中提到的算法