#include <stdio.h>
#include <stdlib.h>

#include "samples/risp4ml/common/image.h"

inline pixel_type_t Pattern(uint16_t c, uint16_t y, uint16_t x) {
  return (pixel_type_t)(x + y * 100 + c * 10000);
}

inline void FillImage(Image* img) {
  for (uint16_t c = 0; c < img->num_channels; ++c) {
    for (uint16_t y = 0; y < img->height; ++y) {
      for (uint16_t x = 0; x < img->width; ++x) {
        *image_pixel(img, c, y, x) = Pattern(c, y, x);
      }
    }
  }
}

// Initializes raw image to random value within min and max range
inline void InitImageRandom(Image* image, pixel_type_t min_val,
                            pixel_type_t max_val) {
  pixel_type_t range = max_val + 1 - min_val;
  for (uint16_t c = 0; c < image->num_channels; ++c) {
    for (uint16_t y = 0; y < image->height; ++y) {
      for (uint16_t x = 0; x < image->width; ++x) {
        *image_pixel(image, 0, y, x) = (pixel_type_t)(rand() % range + min_val);
      }
    }
  }
}

// Initializes raw image to raw pixel value
inline void InitImage(Image* image, pixel_type_t val) {
  for (uint16_t c = 0; c < image->num_channels; ++c) {
    for (uint16_t y = 0; y < image->height; ++y) {
      for (uint16_t x = 0; x < image->width; ++x) {
        *image_pixel(image, 0, y, x) = val;
      }
    }
  }
}
