JeVoisBase  1.0
JeVois Smart Embedded Machine Vision Toolkit Base Modules
env_image.h
Go to the documentation of this file.
1 /*!@file Envision/env_image.h A basic image class */
2 
3 // //////////////////////////////////////////////////////////////////// //
4 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2001 by the //
5 // University of Southern California (USC) and the iLab at USC. //
6 // See http://iLab.usc.edu for information about this project. //
7 // //////////////////////////////////////////////////////////////////// //
8 // Major portions of the iLab Neuromorphic Vision Toolkit are protected //
9 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency //
10 // in Visual Environments, and Applications'' by Christof Koch and //
11 // Laurent Itti, California Institute of Technology, 2001 (patent //
12 // pending; application number 09/912,225 filed July 23, 2001; see //
13 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status). //
14 // //////////////////////////////////////////////////////////////////// //
15 // This file is part of the iLab Neuromorphic Vision C++ Toolkit. //
16 // //
17 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can //
18 // redistribute it and/or modify it under the terms of the GNU General //
19 // Public License as published by the Free Software Foundation; either //
20 // version 2 of the License, or (at your option) any later version. //
21 // //
22 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope //
23 // that it will be useful, but WITHOUT ANY WARRANTY; without even the //
24 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //
25 // PURPOSE. See the GNU General Public License for more details. //
26 // //
27 // You should have received a copy of the GNU General Public License //
28 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write //
29 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, //
30 // Boston, MA 02111-1307 USA. //
31 // //////////////////////////////////////////////////////////////////// //
32 //
33 // Primary maintainer for this file: Rob Peters <rjpeters at usc dot edu>
34 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Envision/env_image.h $
35 // $Id: env_image.h 7645 2007-01-04 21:07:32Z rjpeters $
36 //
37 
38 #pragma once
39 
41 
42 //! Basic image class
43 struct env_image
44 {
45  struct env_dims dims; // width+height of data array
46  intg32* pixels; // data array
47 };
48 
49 #define env_img_initializer { {0,0}, 0 }
50 
51 #ifdef __cplusplus
52 extern "C"
53 {
54 #endif
55 
56  void env_img_init(struct env_image* img, const struct env_dims d);
57 
58  static inline void env_img_init_empty(struct env_image* img);
59 
60  //! Get image size (width * height)
61  static inline env_size_t env_img_size(const struct env_image* img);
62 
63  //! Check whether image is non-empty (i.e., non-zero height and width).
64  static inline int env_img_initialized(const struct env_image* img);
65 
66  void env_img_swap(struct env_image* img1, struct env_image* img2);
67 
68  void env_img_make_empty(struct env_image* img);
69 
70  void env_img_resize_dims(struct env_image* img, const struct env_dims d);
71 
72  static inline const intg32* env_img_pixels(const struct env_image* img);
73 
74  static inline intg32* env_img_pixelsw(struct env_image* img);
75 
76  void env_img_copy_src_dst(const struct env_image* src, struct env_image* dst);
77 
78  static inline int env_dims_equal(const struct env_dims d1, const struct env_dims d2);
79 
80 #ifdef __cplusplus
81 }
82 #endif
83 
84 // ######################################################################
85 static inline void env_img_init_empty(struct env_image* img)
86 {
87  img->pixels = 0;
88  img->dims.w = img->dims.h = 0;
89 }
90 
91 // ######################################################################
92 static inline env_size_t env_img_size(const struct env_image* img)
93 {
94  return img->dims.w * img->dims.h;
95 }
96 
97 // ######################################################################
98 static inline int env_img_initialized(const struct env_image* img)
99 {
100  return (img->dims.w * img->dims.h) > 0;
101 }
102 
103 // ######################################################################
104 static inline const intg32* env_img_pixels(const struct env_image* img)
105 {
106  return img->pixels;
107 }
108 
109 // ######################################################################
110 static inline intg32* env_img_pixelsw(struct env_image* img)
111 {
112  return img->pixels;
113 }
114 
115 // ######################################################################
116 static inline int env_dims_equal(const struct env_dims d1, const struct env_dims d2)
117 {
118  return d1.w == d2.w && d1.h == d2.h;
119 }
env_size_t w
The width.
Definition: env_types.h:82
Basic image class.
Definition: env_image.h:43
void env_img_make_empty(struct env_image *img)
Definition: env_image.c:56
struct env_dims dims
Definition: env_image.h:45
env_size_t h
The height.
Definition: env_types.h:83
unsigned long env_size_t
Definition: env_types.h:71
void env_img_resize_dims(struct env_image *img, const struct env_dims d)
Definition: env_image.c:64
void env_img_copy_src_dst(const struct env_image *src, struct env_image *dst)
Definition: env_image.c:76
intg32 * pixels
Definition: env_image.h:46
ENV_INTG32_TYPE intg32
32-bit signed integer
Definition: env_types.h:52
void env_img_swap(struct env_image *img1, struct env_image *img2)
Definition: env_image.c:48
A simple struct to hold a pair of width/height dimensions.
Definition: env_types.h:80
void env_img_init(struct env_image *img, const struct env_dims d)
Definition: env_image.c:41