process.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing,
  13. * software distributed under the License is distributed on an
  14. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15. * KIND, either express or implied. See the License for the
  16. * specific language governing permissions and limitations
  17. * under the License.
  18. */
  19. /* auto generate by HHB_VERSION "2.0.21" */
  20. #ifndef PROCESS_H_
  21. #define PROCESS_H_
  22. #include <math.h>
  23. #include <stdint.h>
  24. #include <stdio.h>
  25. #include <stdlib.h>
  26. #include <string.h>
  27. #include "io.h"
  28. struct image_data {
  29. float* data; // the data of image
  30. uint32_t* shape; // the shape of image, default to HWC
  31. uint32_t dim; // the number of shape
  32. };
  33. /* Utils to process image data*/
  34. uint32_t get_size(struct image_data img);
  35. float get_value(struct image_data img, uint32_t h_idx, uint32_t w_idx, uint32_t c_idx);
  36. struct image_data* get_input_data(const char* filename, uint32_t size);
  37. void free_image_data(struct image_data* img);
  38. void sub_mean(struct image_data* img, float b_mean, float g_mean, float r_mean);
  39. void data_scale(struct image_data* img, float scale);
  40. void data_crop(struct image_data* img, uint32_t height, uint32_t width);
  41. /* Main image processing operators */
  42. void imresize(struct image_data* img, uint32_t dst_height, uint32_t dst_width);
  43. void imrgb2bgr(struct image_data* img);
  44. void imhwc2chw(struct image_data* img);
  45. void im2rgb(struct image_data* img);
  46. #endif // PROCESS_H_