00001 /*!@file AppPsycho/make-classic-searcharray.C */ 00002 00003 // //////////////////////////////////////////////////////////////////// // 00004 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2000-2005 // 00005 // by the University of Southern California (USC) and the iLab at USC. // 00006 // See http://iLab.usc.edu for information about this project. // 00007 // //////////////////////////////////////////////////////////////////// // 00008 // Major portions of the iLab Neuromorphic Vision Toolkit are protected // 00009 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency // 00010 // in Visual Environments, and Applications'' by Christof Koch and // 00011 // Laurent Itti, California Institute of Technology, 2001 (patent // 00012 // pending; application number 09/912,225 filed July 23, 2001; see // 00013 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status). // 00014 // //////////////////////////////////////////////////////////////////// // 00015 // This file is part of the iLab Neuromorphic Vision C++ Toolkit. // 00016 // // 00017 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can // 00018 // redistribute it and/or modify it under the terms of the GNU General // 00019 // Public License as published by the Free Software Foundation; either // 00020 // version 2 of the License, or (at your option) any later version. // 00021 // // 00022 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope // 00023 // that it will be useful, but WITHOUT ANY WARRANTY; without even the // 00024 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // 00025 // PURPOSE. See the GNU General Public License for more details. // 00026 // // 00027 // You should have received a copy of the GNU General Public License // 00028 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write // 00029 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, // 00030 // Boston, MA 02111-1307 USA. // 00031 // //////////////////////////////////////////////////////////////////// // 00032 // 00033 // Primary maintainer for this file: Rob Peters <rjpeters at usc dot edu> 00034 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/AppPsycho/make-classic-searcharray.C $ 00035 // $Id: make-classic-searcharray.C 9084 2007-12-13 01:00:11Z rjpeters $ 00036 // 00037 00038 #ifndef APPPSYCHO_MAKE_CLASSIC_SEARCHARRAY_C_DEFINED 00039 #define APPPSYCHO_MAKE_CLASSIC_SEARCHARRAY_C_DEFINED 00040 00041 #include "Image/geom.h" 00042 #include "Psycho/ClassicSearchItem.H" 00043 #include "Psycho/SearchArray.H" 00044 #include "Raster/Raster.H" 00045 #include "Util/StringConversions.H" 00046 #include "Util/sformat.H" 00047 #include "rutz/rand.h" 00048 00049 #include <stdio.h> 00050 00051 static double c2r(const char* arg) 00052 { 00053 const double deg = fromStr<double>(arg); 00054 return geom::rad_0_2pi(geom::deg2rad(deg)); 00055 } 00056 00057 int main(int argc, char** argv) 00058 { 00059 if (argc != 11) 00060 { 00061 fprintf(stderr, "usage: %s arrayWxarrayH itemsize " 00062 "fgitemlist fg_min_angle fg_max_angle " 00063 "bgitemlist bg_min_angle bg_max_angle " 00064 "rand_seed outimagestem\n\n" 00065 "available item types: C, O, Q, +, L, T, -\n", 00066 argv[0]); 00067 return -1; 00068 } 00069 00070 const Dims arraydims = fromStr<Dims>(argv[1]); 00071 const int itemsize = fromStr<int>(argv[2]); 00072 00073 const uint seed = fromStr<uint>(argv[9]); 00074 00075 ClassicSearchItemFactory fg(SearchItem::FOREGROUND, argv[3], itemsize, 00076 Range<double>(c2r(argv[4]), c2r(argv[5])), 00077 3, seed + 12345U); 00078 ClassicSearchItemFactory bg(SearchItem::BACKGROUND, argv[6], itemsize, 00079 Range<double>(c2r(argv[7]), c2r(argv[8])), 00080 3, seed + 23456U); 00081 00082 const std::string outimagestem = argv[10]; 00083 00084 rutz::urand fgpos(seed + 34567U); 00085 00086 SearchArray g(arraydims, 85.0, 70.0, itemsize); 00087 g.generateBackground(bg, 2, false, 10000, true, seed + 45678U); 00088 g.replaceElementAtSamePos(fgpos.idraw(g.numElements()), 00089 fg.make(geom::vec2d())); 00090 00091 Raster::WriteGray(g.getImage(0.0, 1.0, 1.0), 00092 sformat("%s.png", outimagestem.c_str())); 00093 00094 g.saveCoords(sformat("%s.txt", outimagestem.c_str())); 00095 } 00096 00097 // ###################################################################### 00098 /* So things look consistent in everyone's emacs... */ 00099 /* Local Variables: */ 00100 /* mode: c++ */ 00101 /* indent-tabs-mode: nil */ 00102 /* End: */ 00103 00104 #endif // APPPSYCHO_MAKE_CLASSIC_SEARCHARRAY_C_DEFINED