mxnet icon indicating copy to clipboard operation
mxnet copied to clipboard

illumination and contrast as image augmentation parameters explained

Open Lopezurrutia opened this issue 9 years ago • 1 comments

I am trying to understand the valid values for the illumination and contrast image augmentation parameters but the docs are quite succint. A value of zero means no change but what are the reasonable range of values that I can use? I tried looking at the code and the relevant section seems to be in src/io/iter_normalize.h (copied bellow) but I get confused by the rand_uniform(rnd_) and I fail to understand the valid ranges of contrast and illumination.

outimg_.Resize(data.shape_);
    float contrast =
        rand_uniform(rnd_) * param_.max_random_contrast * 2 - param_.max_random_contrast + 1;
    float illumination =
        rand_uniform(rnd_) * param_.max_random_illumination * 2 - param_.max_random_illumination;

    if (param_.mean_r > 0.0f || param_.mean_g > 0.0f ||
        param_.mean_b > 0.0f || param_.mean_a > 0.0f) {
      // subtract mean per channel                                                                                                                                              
      data[0] -= param_.mean_r;
      if (data.shape_[0] >= 3) {
        data[1] -= param_.mean_g;
        data[2] -= param_.mean_b;
      }
      if (data.shape_[0] == 4) {
        data[3] -= param_.mean_a;
      }
      if ((param_.rand_mirror && coin_flip(rnd_)) || param_.mirror) {
        outimg_ = mirror(data * contrast + illumination) * param_.scale;
      } else {
        outimg_ = (data * contrast + illumination) * param_.scale;
      }

Lopezurrutia avatar Dec 08 '16 09:12 Lopezurrutia

This issue is closed due to lack of activity in the last 90 days. Feel free to reopen if this is still an active issue. Thanks!

yajiedesign avatar Sep 28 '17 07:09 yajiedesign