You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
2.3 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /** @file pgm.h
  2. ** @brief Portable graymap format (PGM) parser
  3. ** @author Andrea Vedaldi
  4. **/
  5. /*
  6. Copyright (C) 2007-12 Andrea Vedaldi and Brian Fulkerson.
  7. All rights reserved.
  8. This file is part of the VLFeat library and is made available under
  9. the terms of the BSD license (see the COPYING file).
  10. */
  11. #ifndef VL_PGM_H
  12. #define VL_PGM_H
  13. #include "generic.h"
  14. #include "mathop.h"
  15. #include <stdio.h>
  16. /** @name PGM parser error codes
  17. ** @{ */
  18. #define VL_ERR_PGM_INV_HEAD 101 /**< Invalid PGM header section. */
  19. #define VL_ERR_PGM_INV_META 102 /**< Invalid PGM meta section. */
  20. #define VL_ERR_PGM_INV_DATA 103 /**< Invalid PGM data section.*/
  21. #define VL_ERR_PGM_IO 104 /**< Generic I/O error. */
  22. /** @} */
  23. /** @brief PGM image meta data
  24. **
  25. ** A PGM image is a 2-D array of pixels of width #width and height
  26. ** #height. Each pixel is an integer one or two bytes wide, depending
  27. ** whether #max_value is smaller than 256.
  28. **/
  29. typedef struct _VlPgmImage
  30. {
  31. vl_size width ; /**< image width. */
  32. vl_size height ; /**< image height. */
  33. vl_size max_value ; /**< pixel maximum value (<= 2^16-1). */
  34. vl_bool is_raw ; /**< is RAW format? */
  35. } VlPgmImage ;
  36. /** @name Core operations
  37. ** @{ */
  38. VL_EXPORT int vl_pgm_extract_head (FILE *f, VlPgmImage *im) ;
  39. VL_EXPORT int vl_pgm_extract_data (FILE *f, VlPgmImage const *im, void *data) ;
  40. VL_EXPORT int vl_pgm_insert (FILE *f,
  41. VlPgmImage const *im,
  42. void const*data ) ;
  43. VL_EXPORT vl_size vl_pgm_get_npixels (VlPgmImage const *im) ;
  44. VL_EXPORT vl_size vl_pgm_get_bpp (VlPgmImage const *im) ;
  45. /** @} */
  46. /** @name Helper functions
  47. ** @{ */
  48. VL_EXPORT int vl_pgm_write (char const *name,
  49. vl_uint8 const *data,
  50. int width, int height) ;
  51. VL_EXPORT int vl_pgm_write_f (char const *name,
  52. float const *data,
  53. int width, int height) ;
  54. VL_EXPORT int vl_pgm_read_new (char const *name,
  55. VlPgmImage *im,
  56. vl_uint8 **data) ;
  57. VL_EXPORT int vl_pgm_read_new_f (char const *name,
  58. VlPgmImage *im,
  59. float **data) ;
  60. /** @} */
  61. /* VL_PGM_H */
  62. #endif