图像中的Andr​​oid应用筛选时变得过于噪音 [英] images getting as too noise when applying filters in android

查看:219
本文介绍了图像中的Andr​​oid应用筛选时变得过于噪音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个应用程序,其中包括过滤器和农作物了。在这里,我使用的是裁剪库。在这里,我用8 * 8的下尿路症状如样品LUT 。在这里,我要裁剪的过滤图像(8 * 8 LUT)

i am developing an application which includes filters and crop too. here i am using cropping library. here i used 8*8 luts like sample lut. here i want to CROP the filtered image(8*8 lut)

下面是作物的逻辑映像。

here is the logic for crop the image.

Bitmap cropbitmap =ivCropimageView.getCroppedImage();

使用此位图我产生像下面的缩略图位图。

using this bitmap am generating thumbnail bitmap like below.

 Bitmap thumbImage = ThumbnailUtils.extractThumbnail(cropbitmap, 190, 250);

当我试图为所有过滤器缩略图然后缩略图显示太像噪音这个

when i am trying to generate thumbnails for all filters then thumbnails are displaying as too noise like this.

这样的结果就是,当我从<一个实施答案href=\"http://stackoverflow.com/questions/32905539/how-to-apply-color-lut-to-bitmap-images-for-filter-effects-in-android\">renderscript.

this result is when i implemented answer from renderscript.

因此​​,如果任何人有想法,请帮助我..

so if anyone have idea please help me..

感谢

推荐答案

U可以通过这一点,希望这将有助于你得到正确的处理。

u can go through this, hope it will help you to get the right process.

照片是主要的位图在这里。

photo is the main bitmap here.

mLut3D是存储在可拉伸的LUT图像阵列

mLut3D is the array of LUT images stored in drawable

    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;
    }

您增加值MFILTER得到不同的LUT图像不同的滤镜效果,你有,检查出来。

you increase the mFilter value to get different filter effect with different LUT images, you have, check it out.

你可以通过在github上的这个链接更多的帮助,我得到的答案从这里: -
https://github.com/RenderScript/RsLutDemo

you can go through the this link on github for more help, i got the answer from here:- https://github.com/RenderScript/RsLutDemo

希望这将有助于

这篇关于图像中的Andr​​oid应用筛选时变得过于噪音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆