# Revision history [back]

first, forget about the silly Bitmaps, you'll never need any here.

Mat noise = new Mat(img.size(), img.type());


then, for gaussian noise, you'll need the mean and stdev of your image:

MatOfDouble mean = new MatOfDouble ();
MatOfDouble dev = new MatOfDouble ();

Core.meanStdDev(img,mean,dev);

// the java wrappers allow only to apply single numbers here, imho, that's a bug !
Core.randn(noise,mean.get(0,0)[0], dev.get(0,0)[0]);



first, forget about the silly Bitmaps, you'll never need any here.

Mat noise = new Mat(img.size(), img.type());


then, for gaussian noise, you'll need the mean and stdev of your image:

MatOfDouble mean = new MatOfDouble ();
MatOfDouble dev = new MatOfDouble ();

Core.meanStdDev(img,mean,dev);

// the java wrappers allow only to apply single numbers here, imho, that's a bug !
//  if your img has more than 1 channel, you might need to split() it into seperate
//  channels, appl nois on each seperately, and merge() the results
Core.randn(noise,mean.get(0,0)[0], dev.get(0,0)[0]);



first, forget about the silly Bitmaps, you'll never need any here.

Mat noise = new Mat(img.size(), img.type());


then, for gaussian noise, you'll need the mean and stdev of your image:

MatOfDouble mean = new MatOfDouble ();
MatOfDouble dev = new MatOfDouble ();

Core.meanStdDev(img,mean,dev);

// the java wrappers allow only to apply single numbers here, imho, that's a bug !
//  if your img has more than 1 channel, you might need to split() it into seperate
//  channels, appl nois apply noise on each seperately, and merge() the results
Core.randn(noise,mean.get(0,0)[0], dev.get(0,0)[0]);