JeVoisBase  1.20
JeVois Smart Embedded Machine Vision Toolkit Base Modules
Share this page:
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_dims::w
env_size_t w
The width.
Definition: env_types.h:82
demo.img2
img2
Definition: demo.py:63
env_size_t
unsigned long env_size_t
Definition: env_types.h:71
env_img_make_empty
void env_img_make_empty(struct env_image *img)
Definition: env_image.c:56
demo.img1
img1
Definition: demo.py:62
env_img_copy_src_dst
void env_img_copy_src_dst(const struct env_image *src, struct env_image *dst)
Definition: env_image.c:76
env_img_resize_dims
void env_img_resize_dims(struct env_image *img, const struct env_dims d)
Definition: env_image.c:64
env_dims::h
env_size_t h
The height.
Definition: env_types.h:83
env_image::dims
struct env_dims dims
Definition: env_image.h:45
env_img_swap
void env_img_swap(struct env_image *img1, struct env_image *img2)
Definition: env_image.c:48
env_image::pixels
intg32 * pixels
Definition: env_image.h:46
env_img_init
void env_img_init(struct env_image *img, const struct env_dims d)
Definition: env_image.c:41
env_types.h
env_image
Basic image class.
Definition: env_image.h:43
intg32
ENV_INTG32_TYPE intg32
32-bit signed integer
Definition: env_types.h:52
env_dims
A simple struct to hold a pair of width/height dimensions.
Definition: env_types.h:80