【问题标题】:How to find given bitmap image is blurred image or unblurred image in android如何在android中找到给定的位图图像是模糊图像或未模糊图像
【发布时间】:2014-01-20 17:37:55
【问题描述】:

在我的 android 应用程序中,我需要找到给定/相机捕获的图像是否模糊。 我使用 openCV 库帮助中的以下代码。但它不会总是给出正确的结果。 请帮助我,在此先感谢。

private boolean isBlurredImage(Bitmap image) {
    BitmapFactory.Options opt = new BitmapFactory.Options();
    opt.inDither = true;
    opt.inPreferredConfig = Bitmap.Config.ARGB_8888;

    int l = CvType.CV_8UC1;
    Mat matImage = new Mat();
    Utils.bitmapToMat(image, matImage);
    Mat matImageGrey = new Mat();
    Imgproc.cvtColor(matImage, matImageGrey, Imgproc.COLOR_BGR2GRAY);

    Mat dst2 = new Mat();
    Utils.bitmapToMat(image, dst2);

    Mat laplacianImage = new Mat();
    dst2.convertTo(laplacianImage, l);
    Imgproc.Laplacian(matImageGrey, laplacianImage, CvType.CV_8U);
    Mat laplacianImage8bit = new Mat();
    laplacianImage.convertTo(laplacianImage8bit, l);
    System.gc();

    Bitmap bmp = Bitmap.createBitmap(laplacianImage8bit.cols(),
            laplacianImage8bit.rows(), Bitmap.Config.ARGB_8888);

    Utils.matToBitmap(laplacianImage8bit, bmp);

    int[] pixels = new int[bmp.getHeight() * bmp.getWidth()];
    bmp.getPixels(pixels, 0, bmp.getWidth(), 0, 0, bmp.getWidth(),
            bmp.getHeight());
    if (bmp != null)
        if (!bmp.isRecycled()) {
            bmp.recycle();

        }
    int maxLap = -16777216;

    for (int i = 0; i < pixels.length; i++) {

        if (pixels[i] > maxLap) {
            maxLap = pixels[i];
        }
    }
    int soglia = -6118750;

    if (maxLap < soglia || maxLap == soglia) {
        Log.i(MIOTAG, "--------->blur image<------------");
        return true;
    } else {
        Log.i(MIOTAG, "----------->Not blur image<------------");
        return false;
    }
}

【问题讨论】:

  • 可以使用openCV java颜色检测来检测...
  • @VenuNalla ,在这里我只需要给定图像(颜色或背面和白色)是否模糊。
  • 你的问题不完整,请详细说明...
  • @VenuNalla ,当用户从相机捕获图像时。我需要发现图像是否模糊。
  • 我认为如果你使用有符号类型(或者可能更好地使用实类型)而不是无符号字符,你会得到更好的结果,因为拉普拉斯算子给你正值和负值,而不仅仅是正值。并使用 Laplcaian 绝对值与阈值进行比较。

标签: android image opencv bitmap blur


【解决方案1】:

This 是我读过的关于失焦图像的最佳文章之一。它由惠普研究人员制作,并在他们的一些相机中实现。它基本上将图像分割成小方块(如网格)并计算每个区域的模糊因子。之后,根据决策树做出最终决定(是否模糊图像)。

我希望这会帮助你完成你的工作。

最好的问候!

【讨论】:

  • 大家好,我想获取图像是否模糊。请帮助我。我正在实现上面的代码,但它崩溃了..06-04 11:38:05.005: E/AndroidRuntime(4704): FATAL EXCEPTION: main 06-04 11:38:05.005: E/AndroidRuntime(4704) : java.lang.UnsatisfiedLinkError: n_Mat
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2010-11-02
  • 2015-06-10
  • 2010-12-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多