Ask Your Question
0

getting black image in local standard deviation

asked 2014-10-31 12:48:52 -0600

Deepak Kumar gravatar image

updated 2014-11-01 09:24:28 -0600

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 !!

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2014-11-02 03:10:43 -0600

berak gravatar image

you normalized the output image to [0..1] range. (yep, that will look pretty dark)

so, map it back to [0..255] range, when converting it to CV_8U:

gry.convertTo(gry, CvType.CV_8U, 255);
edit flag offensive delete link more

Comments

yes, i got the solution....thanks.

i am not able to get these silly things, can u tell me what should i do to have this concept. i codes blindly and i am not able to find these problem. should i prefer some book.

thanks!!

Deepak Kumar gravatar imageDeepak Kumar ( 2014-11-02 09:36:05 -0600 )edit

Question Tools

Stats

Asked: 2014-10-31 12:48:52 -0600

Seen: 345 times

Last updated: Nov 02 '14