JeVoisBase  1.20
JeVois Smart Embedded Machine Vision Toolkit Base Modules
Share this page:
env_pyr.c
Go to the documentation of this file.
1 /*!@file Envision/env_pyr.c */
2 
3 // //////////////////////////////////////////////////////////////////// //
4 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2000-2005 //
5 // by the 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_pyr.c $
35 // $Id: env_pyr.c 7628 2007-01-03 04:07:21Z rjpeters $
36 //
37 
39 
40 // ######################################################################
41 void env_pyr_init(struct env_pyr* pyr, const env_size_t n)
42 {
43  pyr->images = (struct env_image*)env_allocate(n * sizeof(struct env_image));
44 
45  pyr->depth = n;
46 
47  for (env_size_t i = 0; i < pyr->depth; ++i) env_img_init_empty(&pyr->images[i]);
48 }
49 
50 // ######################################################################
51 void env_pyr_make_empty(struct env_pyr* dst)
52 {
53  for (env_size_t i = 0; i < dst->depth; ++i) env_img_make_empty(&dst->images[i]);
54  env_deallocate(dst->images);
55  dst->images = 0;
56  dst->depth = 0;
57 }
58 
59 // ######################################################################
60 void env_pyr_swap(struct env_pyr* pyr1, struct env_pyr* pyr2)
61 {
62  const struct env_pyr pyr1copy = *pyr1;
63  *pyr1 = *pyr2;
64  *pyr2 = pyr1copy;
65 }
66 
67 // ######################################################################
68 void env_pyr_copy_src_dst(const struct env_pyr* src, struct env_pyr* dst)
69 {
70  if (dst == src) return;
71 
72  if (dst->depth != src->depth)
73  {
74  for (env_size_t i = 0; i < dst->depth; ++i) env_img_make_empty(&dst->images[i]);
75  env_deallocate(dst->images);
76  dst->images = (struct env_image*)env_allocate(src->depth * sizeof(struct env_image));
77  dst->depth = src->depth;
78  for (env_size_t i = 0; i < dst->depth; ++i) env_img_init_empty(&dst->images[i]);
79  }
80 
81  for (env_size_t i = 0; i < dst->depth; ++i) env_img_copy_src_dst(&src->images[i], &dst->images[i]);
82 }
env_pyr_swap
void env_pyr_swap(struct env_pyr *pyr1, struct env_pyr *pyr2)
Swap contents with another env_pyr.
Definition: env_pyr.c:60
env_allocate
void * env_allocate(unsigned long nbytes)
Definition: env_config.h:58
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
env_pyr_init
void env_pyr_init(struct env_pyr *pyr, const env_size_t n)
Construct with a given number of empty images.
Definition: env_pyr.c:41
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_pyr::images
struct env_image * images
Definition: env_pyr.h:47
env_pyr::depth
env_size_t depth
Definition: env_pyr.h:48
env_pyr
This class implements a set of images, often used as a dyadic pyramid.
Definition: env_pyr.h:45
env_pyr.h
env_deallocate
void env_deallocate(void *mem)
Definition: env_config.h:59
env_pyr_copy_src_dst
void env_pyr_copy_src_dst(const struct env_pyr *src, struct env_pyr *dst)
Definition: env_pyr.c:68
env_image
Basic image class.
Definition: env_image.h:43
env_pyr_make_empty
void env_pyr_make_empty(struct env_pyr *dst)
Definition: env_pyr.c:51