Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

getting black image in local standard deviation

hi, i am following this link to get the standard deviation of image. http://stackoverflow.com/questions/11456565/opencv-mean-sd-filter i have ported the same code in android and i am getting completely black image. According to me there should be for changing the image format from 8uint to float againg to 8uing but I exactly dont know the reason why it is so. the same code in opencv c++ i am getting the perfect result but not getting in android.

Here is android code :- Bitmap bmp = t1.copy(Bitmap.Config.ARGB_8888, true);

    Utils.bitmapToMat(bmp, rgb);

    Imgproc.cvtColor(rgb, rgb, Imgproc.COLOR_RGB2GRAY);

    rgb.convertTo(rgb32f, CvType.CV_32F);

    Mat mu = new Mat();     
    Size ksize = new Size(3,3);
    Imgproc.blur(rgb32f, mu,ksize);

    Mat mu2 = new Mat();
    Imgproc.blur(rgb32f.mul(rgb32f), mu2, ksize);

    Mat sigma = new Mat();
    Mat x = new Mat();
    Mat y = new Mat();
    Core.multiply(mu, mu, x);
    Core.subtract(mu2, x, y);
    Core.sqrt(y, sigma);

    Core.normalize(sigma, gry, 0.0, 1.0, Core.NORM_MINMAX);

    Bitmap scale = Bitmap.createBitmap(gry.cols(), gry.rows(), Bitmap.Config.ARGB_8888);


    gry.convertTo(gry, CvType.CV_8U);
    Utils.matToBitmap(gry, scale);

thanks !!

getting black image in local standard deviation

hi, i am following this link to get the standard deviation of image. http://stackoverflow.com/questions/11456565/opencv-mean-sd-filter i have ported the same code in android and i am getting completely black image. According to me there should be for changing the image format from 8uint to float againg to 8uing but I exactly dont know the reason why it is so. the same code in opencv c++ i am getting the perfect result but not getting in android.

Here is android code :- Bitmap bmp = t1.copy(Bitmap.Config.ARGB_8888, true);

    Utils.bitmapToMat(bmp, rgb);

    Imgproc.cvtColor(rgb, rgb, Imgproc.COLOR_RGB2GRAY);

    rgb.convertTo(rgb32f, CvType.CV_32F);

    Mat mu = new Mat();     
    Size ksize = new Size(3,3);
    Imgproc.blur(rgb32f, mu,ksize);

    Mat mu2 = new Mat();
    Imgproc.blur(rgb32f.mul(rgb32f), mu2, ksize);

    Mat sigma = new Mat();
    Mat x = new Mat();
    Mat y = new Mat();
    Core.multiply(mu, mu, x);
    Core.subtract(mu2, x, y);
    Core.sqrt(y, sigma);

    Core.normalize(sigma, gry, 0.0, 1.0, Core.NORM_MINMAX);

    Bitmap scale = Bitmap.createBitmap(gry.cols(), gry.rows(), Bitmap.Config.ARGB_8888);


    gry.convertTo(gry, CvType.CV_8U);
    Utils.matToBitmap(gry, scale);

thanks !!