问题描述
我正在开发一个应用程序,其中包括过滤器和农作物了。在这里,我使用的是。在这里,我用8 * 8的下尿路症状如。在这里,我要裁剪的过滤图像(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.
这样的结果就是,当我从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上的这个链接更多的帮助,我得到的答案从这里: -
you can go through the this link on github for more help, i got the answer from here:- https://github.com/RenderScript/RsLutDemo
希望这将有助于
这篇关于图像中的Android应用筛选时变得过于噪音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!