How to add Gaussian noise in JAVA [closed]

asked 2019-01-21 20:24:00 -0500

cz11@hw.ac.uk gravatar image

updated 2019-01-21 20:59:53 -0500

Mat img = new Mat(); Utils.bitmapToMat(grayBitmap,img); noiseBitmap = grayBitmap.copy(Bitmap.Config.RGB_565,true); Mat noiseMat = new Mat(img.size(),CvType.CV_64F); Mat result = new Mat(); Core.normalize(img,result,0,1,Core.NORM_MINMAX,CvType.CV_64F); Core.randn(noiseMat,0,0.1); Core.add(result,noiseMat,result); Core.normalize(result,result,0,1,Core.NORM_MINMAX,CvType.CV_64F); result.convertTo(result,CvType.CV_32F,255,0); Utils.matToBitmap(result,noiseBitmap); ivImage.setImageBitmap(noiseBitmap);

This is the part of the codes to add Gaussian noise, but it does not work anyway, thx for any help and advice. When I debug, I found that the Error is following,Error: Sizes of input arguments do not match (The operation is neither 'array op array' (where arrays have the same size and the same number of channels), nor 'array op scalar', nor 'scalar op array') in void cv::arithm_op(cv::InputArray, cv::InputArray, cv::OutputArray, cv::InputArray, int, void (*)(const uchar, size_t, const uchar, size_t, uchar, size_t, int, int, void), bool, void, int), file /build/master_pack-android/opencv/modules/core/src/arithm.cpp, line 659

edit retag flag offensive reopen merge delete

Closed for the following reason duplicate question by berak
close date 2019-01-22 01:06:41.438634

Comments

please rather update your previous question to the same topic, thank you !

berak gravatar imageberak ( 2019-01-22 01:07:29 -0500 )edit