How to Add Noise

A task which is often required to be performed is to add noise to the data. Epina ImageLab basically provides three different ways to do so:

Using the built-in calculator: Use the equation editor (command Tools>Mathematical Transformations) and enter the following formula (assuming a standard deviation of 1.0): all=+gauss. For standard deviations other than 1.0 you have to multiply the gauss function by the standard deviation. For example, the formula all=+3.5*gauss adds normally distributed noise of a standard deviation of 3.5. Please note that the calculation may require plenty of time since the formula is parsed and interpreted for each and every cell of the hyperspectral dataset.

Using the bulk transform tool: Epina ImageLab offers a tool for performing often needed operations which provides an option to add noise. Click the command Preprocessing > Predefined Arithmetic Conversions to open this tool and select "Add Noise" as the conversion mode.

Writing a small script: The following script shows how to add noise to the data. First, the user is asked for the amplitudes of homo- and heteroscedastic noise. The script uses the bulk transform function to create the noise:

program AddNoise;

var
  sl             : integer;
  errcnt         : integer;
  DlgResult      : TVariantArray;
  errcode        : integer;

begin
sl := GetCubeSize(dimL);          // the number of layers
CreateDialog (200, 20,            // AlignAt, TopPos
              'Adding Noise',     // DialogCaption
              [gcLabel, gcNumio, gcNumio], // Components
              ['Please set the noise amplitudes',
               'Homoscedastic','Heteroscedastic']); // Captions
ConfigDlgComponent(2, 'low=0; high=100; prec=0; val=10');
ConfigDlgComponent(3, 'low=0; high=2.0; prec=2; inc=0.05');
DlgResult := ShowDialog;
if DlgResult[0] = 0 then
  begin
  errcode := PerformBulkTransform
                (15,          // ConversionMode = Add Noise
                 0,           // BitMask
                 1,           // TimeSlot,
                 1, sl,       // FirstLayer, LastLayer
                 DlgResult[2],// ParA
                 DlgResult[3],// ParB
                 true,        // FeedBack
                 errcnt);     // ErrCnt
  if errcode = 0
    then MessageDlg('Noise has been successfully added',
                    mtInformation, [mbok])
    else MessageDlg('The following error occurred: '+IntToStr(errcode),
                    mtError, [mbok])
  end;
end.