saliency_map.h
説明を見る。
1 //
2 // Copyright (c) 2003-2011, MIST Project, Nagoya University
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without modification,
6 // are permitted provided that the following conditions are met:
7 //
8 // 1. Redistributions of source code must retain the above copyright notice,
9 // this list of conditions and the following disclaimer.
10 //
11 // 2. Redistributions in binary form must reproduce the above copyright notice,
12 // this list of conditions and the following disclaimer in the documentation
13 // and/or other materials provided with the distribution.
14 //
15 // 3. Neither the name of the Nagoya University nor the names of its contributors
16 // may be used to endorse or promote products derived from this software
17 // without specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
20 // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
21 // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
22 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25 // IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
26 // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 //
28 
33 
34 #ifndef __INCLUDE_MIST_SALIENCY_MAP__
35 #define __INCLUDE_MIST_SALIENCY_MAP__
36 
37 #ifndef __INCLUDE_MIST_H__
38 #include "mist.h"
39 #endif
40 
41 #ifndef __INCLUDE_MIST_COLOR_H__
42 #include "config/color.h"
43 #endif
44 
45 #ifndef __INCLUDE_MIST_INTERPOLATE__
46 #include "interpolate.h"
47 #endif
48 
49 #ifndef __INCLUDE_FILTER_LINEAR_FILTER_H__
50 #include "filter/linear.h"
51 #endif
52 
53 
54 // mist名前空間の始まり
56 
57 // Saliency map用のGabor filter
58 namespace gabor
59 {
60  typedef double value_type;
61  typedef mist::array2< value_type > kernel_type;
62 
64  value_type GABOR_KERNELS[ ][ 17 ][ 17 ] = { { { -0.000213458164049294360000, -0.000216644186888885490000, -0.000267420737091965140000, -0.000216644186888885440000, 0.000150241317361511160000, -0.000216644186888885630000, -0.00141849613025914330000, -0.000216644186888885380000, 0.00156829918464734320000, -0.000216644186888885380000, -0.00141849613025914330000, -0.000216644186888885630000, 0.000150241317361511160000, -0.000216644186888885440000, -0.000267420737091965140000, -0.000216644186888885490000, -0.000213458164049294360000 },
65  { -0.000202603142700600670000, -0.000216644186888885520000, -0.000440420293033059370000, -0.000216644186888885280000, 0.001400248044141730000, -0.000216644186888886090000, -0.00551329681440221750000, -0.000216644186888885060000, 0.0076497365690452760000, -0.000216644186888885060000, -0.00551329681440221750000, -0.000216644186888886090000, 0.001400248044141730000, -0.000216644186888885280000, -0.000440420293033059370000, -0.000216644186888885520000, -0.000202603142700600670000 },
66  { -0.000165867636685805850000, -0.00021664418688888560000, -0.00102588447810310350000, -0.000216644186888884760000, 0.00563051421821007290000, -0.000216644186888887630000, -0.019370899699708920000, -0.000216644186888883920000, 0.0282305049007476120000, -0.000216644186888883920000, -0.019370899699708920000, -0.000216644186888887630000, 0.00563051421821007290000, -0.000216644186888884760000, -0.00102588447810310350000, -0.00021664418688888560000, -0.000165867636685805850000 },
67  { -6.59695199285921010000e-005, -0.000216644186888885790000, -0.0026179891164260210000, -0.000216644186888883320000, 0.0171342518828273910000, -0.000216644186888891860000, -0.0570551071924256320000, -0.00021664418688888080000, 0.0841976119531329390000, -0.00021664418688888080000, -0.0570551071924256320000, -0.000216644186888891860000, 0.0171342518828273910000, -0.000216644186888883320000, -0.0026179891164260210000, -0.000216644186888885790000, -6.59695199285921010000e-005 },
68  { 0.000150241317361511160000, -0.00021664418688888620000, -0.00606380259198784420000, -0.000216644186888880180000, 0.0420319459852840570000, -0.0002166441868889010000, -0.138615544156578060000, -0.000216644186888874080000, 0.205327974259260050000, -0.000216644186888874080000, -0.138615544156578060000, -0.0002166441868889010000, 0.0420319459852840570000, -0.000216644186888880180000, -0.00606380259198784420000, -0.00021664418688888620000, 0.000150241317361511160000 },
69  { 0.000516406710280523270000, -0.000216644186888886870000, -0.0118994843784274890000, -0.000216644186888874870000, 0.0841976119531329390000, -0.000216644186888916470000, -0.276742799117225710000, -0.000216644186888862720000, 0.410469156191473670000, -0.000216644186888862720000, -0.276742799117225710000, -0.000216644186888916470000, 0.0841976119531329390000, -0.000216644186888874870000, -0.0118994843784274890000, -0.000216644186888886870000, 0.000516406710280523270000 },
70  { 0.000985207756481372430000, -0.000216644186888887770000, -0.019370899699708920000, -0.000216644186888868090000, 0.13818225578280030000, -0.000216644186888936290000, -0.45358693263348410000, -0.000216644186888848140000, 0.673111127738935560000, -0.000216644186888848140000, -0.45358693263348410000, -0.000216644186888936290000, 0.13818225578280030000, -0.000216644186888868090000, -0.019370899699708920000, -0.000216644186888887770000, 0.000985207756481372430000 },
71  { 0.001400248044141730000, -0.000216644186888888560000, -0.0259855145545702070000, -0.000216644186888862070000, 0.185976095591570160000, -0.000216644186888953820000, -0.610151088452771220000, -0.000216644186888835240000, 0.905634071759926610000, -0.000216644186888835240000, -0.610151088452771220000, -0.000216644186888953820000, 0.185976095591570160000, -0.000216644186888862070000, -0.0259855145545702070000, -0.000216644186888888560000, 0.001400248044141730000 },
72  { 0.00156829918464734320000, -0.000216644186888888850000, -0.0286637932745253820000, -0.000216644186888859660000, 0.205327974259260050000, -0.000216644186888960930000, -0.673544416112713430000, -0.000216644186888830040000, 0.999783355813111060000, -0.000216644186888830040000, -0.673544416112713430000, -0.000216644186888960930000, 0.205327974259260050000, -0.000216644186888859660000, -0.0286637932745253820000, -0.000216644186888888850000, 0.00156829918464734320000 },
73  { 0.001400248044141730000, -0.000216644186888888560000, -0.0259855145545702070000, -0.000216644186888862070000, 0.185976095591570160000, -0.000216644186888953820000, -0.610151088452771220000, -0.000216644186888835240000, 0.905634071759926610000, -0.000216644186888835240000, -0.610151088452771220000, -0.000216644186888953820000, 0.185976095591570160000, -0.000216644186888862070000, -0.0259855145545702070000, -0.000216644186888888560000, 0.001400248044141730000 },
74  { 0.000985207756481372430000, -0.000216644186888887770000, -0.019370899699708920000, -0.000216644186888868090000, 0.13818225578280030000, -0.000216644186888936290000, -0.45358693263348410000, -0.000216644186888848140000, 0.673111127738935560000, -0.000216644186888848140000, -0.45358693263348410000, -0.000216644186888936290000, 0.13818225578280030000, -0.000216644186888868090000, -0.019370899699708920000, -0.000216644186888887770000, 0.000985207756481372430000 },
75  { 0.000516406710280523270000, -0.000216644186888886870000, -0.0118994843784274890000, -0.000216644186888874870000, 0.0841976119531329390000, -0.000216644186888916470000, -0.276742799117225710000, -0.000216644186888862720000, 0.410469156191473670000, -0.000216644186888862720000, -0.276742799117225710000, -0.000216644186888916470000, 0.0841976119531329390000, -0.000216644186888874870000, -0.0118994843784274890000, -0.000216644186888886870000, 0.000516406710280523270000 },
76  { 0.000150241317361511160000, -0.00021664418688888620000, -0.00606380259198784420000, -0.000216644186888880180000, 0.0420319459852840570000, -0.0002166441868889010000, -0.138615544156578060000, -0.000216644186888874080000, 0.205327974259260050000, -0.000216644186888874080000, -0.138615544156578060000, -0.0002166441868889010000, 0.0420319459852840570000, -0.000216644186888880180000, -0.00606380259198784420000, -0.00021664418688888620000, 0.000150241317361511160000 },
77  { -6.59695199285921010000e-005, -0.000216644186888885790000, -0.0026179891164260210000, -0.000216644186888883320000, 0.0171342518828273910000, -0.000216644186888891860000, -0.0570551071924256320000, -0.00021664418688888080000, 0.0841976119531329390000, -0.00021664418688888080000, -0.0570551071924256320000, -0.000216644186888891860000, 0.0171342518828273910000, -0.000216644186888883320000, -0.0026179891164260210000, -0.000216644186888885790000, -6.59695199285921010000e-005 },
78  { -0.000165867636685805850000, -0.00021664418688888560000, -0.00102588447810310350000, -0.000216644186888884760000, 0.00563051421821007290000, -0.000216644186888887630000, -0.019370899699708920000, -0.000216644186888883920000, 0.0282305049007476120000, -0.000216644186888883920000, -0.019370899699708920000, -0.000216644186888887630000, 0.00563051421821007290000, -0.000216644186888884760000, -0.00102588447810310350000, -0.00021664418688888560000, -0.000165867636685805850000 },
79  { -0.000202603142700600670000, -0.000216644186888885520000, -0.000440420293033059370000, -0.000216644186888885280000, 0.001400248044141730000, -0.000216644186888886090000, -0.00551329681440221750000, -0.000216644186888885060000, 0.0076497365690452760000, -0.000216644186888885060000, -0.00551329681440221750000, -0.000216644186888886090000, 0.001400248044141730000, -0.000216644186888885280000, -0.000440420293033059370000, -0.000216644186888885520000, -0.000202603142700600670000 },
80  { -0.000213458164049294360000, -0.000216644186888885490000, -0.000267420737091965140000, -0.000216644186888885440000, 0.000150241317361511160000, -0.000216644186888885630000, -0.00141849613025914330000, -0.000216644186888885380000, 0.00156829918464734320000, -0.000216644186888885380000, -0.00141849613025914330000, -0.000216644186888885630000, 0.000150241317361511160000, -0.000216644186888885440000, -0.000267420737091965140000, -0.000216644186888885490000, -0.000213458164049294360000 } },
81  { { -0.000214134630995543680000, -0.000223776723112709650000, -0.000265786932032037330000, -0.000260486197811391280000, 4.97134655875106870000e-005, 0.000473356818591131160000, -8.17539241526291530000e-005, -0.00157541215951787070000, -0.00174750913491093460000, -8.81425456724273390000e-005, 0.000899967028943327880000, 0.000330813391145330870000, -0.000313327068380500440000, -0.000363588772779722020000, -0.000246397192664999550000, -0.00020940739692195480000, -0.000212455820116682450000 },
82  { -0.000223776723112709650000, -0.000276752245330171990000, -0.000282242920061493450000, 0.000264630954308320160000, 0.00130408425975803420000, 0.000144252542662046390000, -0.00467000861014636990000, -0.00633109010842272490000, 0.000404658013336243150000, 0.00639879059704404240000, 0.00373276550870103390000, -0.00107580924696983940000, -0.00180326268368728290000, -0.000617847560383964750000, -0.000116281707141739880000, -0.000153761896758942150000, -0.000209407396921954830000 },
83  { -0.000265786932032037330000, -0.000282242920061493450000, 0.000369653036981674190000, 0.00204139576350936950000, 0.000435739447470087230000, -0.0100406499670049570000, -0.0166541339484946040000, 0.00181635064276655070000, 0.0261901829988486910000, 0.0189938484443885790000, -0.00531556469607083990000, -0.0116869818686263660000, -0.00375726491171347180000, 0.000850593343845249870000, 0.000593598448257943650000, -0.000116281707141740460000, -0.000246397192664999660000 },
84  { -0.000260486197811391280000, 0.000264630954308320160000, 0.00204139576350936650000, 0.00057817812008419990000, -0.0148073585873103630000, -0.0299680542957719880000, 0.00426632915846320620000, 0.0707639371444771930000, 0.0627112466972920560000, -0.020575313029809510000, -0.0560251303734258590000, -0.0212138851397783850000, 0.0074884308558516030000, 0.00691012479671693210000, 0.000850593343845247050000, -0.000617847560383965940000, -0.000363588772779721920000 },
85  { 4.97134655875090610000e-005, 0.00130408425975803520000, 0.000435739447470087230000, -0.0148073585873103630000, -0.036474065750403670000, 0.00644080571244505780000, 0.128251963105421830000, 0.138582356490498270000, -0.0549429945321079360000, -0.183037643453210440000, -0.0840438371584509430000, 0.0372656250325677850000, 0.042032948329216710000, 0.00748843085585157960000, -0.00375726491171348220000, -0.00180326268368728250000, -0.000313327068380500060000 },
86  { 0.000473356818591131590000, 0.000144252542662051760000, -0.0100406499670049570000, -0.0299680542957719880000, 0.00644080571244505780000, 0.156344196320753580000, 0.205921701841042190000, -0.0992679611922332730000, -0.403466596458147640000, -0.225548122324692350000, 0.122566351210613960000, 0.168447184789459910000, 0.0372656250325676670000, -0.0212138851397784230000, -0.0116869818686263630000, -0.00107580924696983480000, 0.000330813391145331730000 },
87  { -8.17539241526270390000e-005, -0.00467000861014636990000, -0.0166541339484945930000, 0.0042663291584632080000, 0.128251963105421670000, 0.205921701841042190000, -0.120927903064719770000, -0.599108144764422870000, -0.408050183798901730000, 0.270604912971661450000, 0.453154646603639020000, 0.122566351210613680000, -0.0840438371584510820000, -0.0560251303734258170000, -0.0053155646960708260000, 0.00373276550870103650000, 0.000899967028943327010000 },
88  { -0.00157541215951787070000, -0.00633109010842273020000, 0.00181635064276650390000, 0.0707639371444771380000, 0.138582356490498380000, -0.0992679611922332730000, -0.599108144764422650000, -0.497232067982842470000, 0.401996425008270990000, 0.820349877738402070000, 0.270604912971661280000, -0.225548122324692460000, -0.183037643453210440000, -0.020575313029809510000, 0.0189938484443886170000, 0.00639879059704402940000, -8.81425456724330850000e-005 },
89  { -0.00174750913491093460000, 0.000404658013336229270000, 0.0261901829988486730000, 0.0627112466972920970000, -0.0549429945321079360000, -0.403466596458147590000, -0.408050183798901730000, 0.401996425008270990000, 0.99978435815704370000, 0.401996425008270990000, -0.408050183798901730000, -0.403466596458147590000, -0.0549429945321079360000, 0.0627112466972920970000, 0.0261901829988486730000, 0.000404658013336229270000, -0.00174750913491093460000 },
90  { -8.81425456724330850000e-005, 0.00639879059704402940000, 0.0189938484443886170000, -0.020575313029809510000, -0.183037643453210440000, -0.225548122324692460000, 0.270604912971661280000, 0.820349877738402070000, 0.401996425008270990000, -0.497232067982842470000, -0.599108144764422650000, -0.0992679611922332730000, 0.138582356490498380000, 0.0707639371444771380000, 0.00181635064276650390000, -0.00633109010842273020000, -0.00157541215951787070000 },
91  { 0.000899967028943327010000, 0.00373276550870103650000, -0.0053155646960708260000, -0.0560251303734258170000, -0.0840438371584510820000, 0.122566351210613680000, 0.453154646603639020000, 0.270604912971661450000, -0.408050183798901730000, -0.599108144764422870000, -0.120927903064719770000, 0.205921701841042190000, 0.128251963105421670000, 0.0042663291584632080000, -0.0166541339484945930000, -0.00467000861014636990000, -8.17539241526270390000e-005 },
92  { 0.000330813391145331730000, -0.00107580924696983480000, -0.0116869818686263630000, -0.0212138851397784230000, 0.0372656250325676670000, 0.168447184789459910000, 0.122566351210613960000, -0.225548122324692350000, -0.403466596458147640000, -0.0992679611922332730000, 0.205921701841042190000, 0.156344196320753580000, 0.00644080571244505780000, -0.0299680542957719880000, -0.0100406499670049570000, 0.000144252542662051760000, 0.000473356818591131590000 },
93  { -0.000313327068380500060000, -0.00180326268368728250000, -0.00375726491171348220000, 0.00748843085585157960000, 0.042032948329216710000, 0.0372656250325677850000, -0.0840438371584509430000, -0.183037643453210440000, -0.0549429945321079360000, 0.138582356490498270000, 0.128251963105421830000, 0.00644080571244505780000, -0.036474065750403670000, -0.0148073585873103630000, 0.000435739447470087230000, 0.00130408425975803520000, 4.97134655875090610000e-005 },
94  { -0.000363588772779721920000, -0.000617847560383965940000, 0.000850593343845247050000, 0.00691012479671693210000, 0.0074884308558516030000, -0.0212138851397783850000, -0.0560251303734258590000, -0.020575313029809510000, 0.0627112466972920560000, 0.0707639371444771930000, 0.00426632915846320620000, -0.0299680542957719880000, -0.0148073585873103630000, 0.00057817812008419990000, 0.00204139576350936650000, 0.000264630954308320160000, -0.000260486197811391280000 },
95  { -0.000246397192664999660000, -0.000116281707141740460000, 0.000593598448257943650000, 0.000850593343845249870000, -0.00375726491171347180000, -0.0116869818686263660000, -0.00531556469607083990000, 0.0189938484443885790000, 0.0261901829988486910000, 0.00181635064276655070000, -0.0166541339484946040000, -0.0100406499670049570000, 0.000435739447470087230000, 0.00204139576350936950000, 0.000369653036981674190000, -0.000282242920061493450000, -0.000265786932032037330000 },
96  { -0.000209407396921954830000, -0.000153761896758942150000, -0.000116281707141739880000, -0.000617847560383964750000, -0.00180326268368728290000, -0.00107580924696983940000, 0.00373276550870103390000, 0.00639879059704404240000, 0.000404658013336243150000, -0.00633109010842272490000, -0.00467000861014636990000, 0.000144252542662046390000, 0.00130408425975803420000, 0.000264630954308320160000, -0.000282242920061493450000, -0.000276752245330171990000, -0.000223776723112709650000 },
97  { -0.000212455820116682450000, -0.00020940739692195480000, -0.000246397192664999550000, -0.000363588772779722020000, -0.000313327068380500440000, 0.000330813391145330870000, 0.000899967028943327880000, -8.81425456724273390000e-005, -0.00174750913491093460000, -0.00157541215951787070000, -8.17539241526291530000e-005, 0.000473356818591131160000, 4.97134655875106870000e-005, -0.000260486197811391280000, -0.000265786932032037330000, -0.000223776723112709650000, -0.000214134630995543680000 } },
98  { { -0.000213458164049299130000, -0.000202603142700605410000, -0.000165867636685810620000, -6.59695199285968710000e-005, 0.000150241317361506390000, 0.00051640671028051850000, 0.000985207756481367660000, 0.00140024804414172520000, 0.00156829918464733840000, 0.00140024804414172520000, 0.000985207756481367660000, 0.00051640671028051850000, 0.000150241317361506390000, -6.59695199285971420000e-005, -0.00016586763668581070000, -0.000202603142700605470000, -0.000213458164049299130000 },
99  { -0.000216644186888890240000, -0.000216644186888890290000, -0.000216644186888890370000, -0.000216644186888890560000, -0.000216644186888890970000, -0.000216644186888891650000, -0.000216644186888892540000, -0.000216644186888893330000, -0.000216644186888893620000, -0.000216644186888893330000, -0.000216644186888892540000, -0.000216644186888891650000, -0.000216644186888890970000, -0.000216644186888890560000, -0.000216644186888890370000, -0.000216644186888890290000, -0.000216644186888890290000 },
100  { -0.000267420737091969860000, -0.000440420293033064140000, -0.00102588447810310820000, -0.00261798911642602580000, -0.00606380259198784860000, -0.0118994843784274940000, -0.0193708996997089270000, -0.0259855145545702140000, -0.0286637932745253880000, -0.0259855145545702140000, -0.0193708996997089270000, -0.0118994843784274940000, -0.00606380259198784860000, -0.00261798911642602580000, -0.00102588447810310820000, -0.000440420293033064140000, -0.000267420737091969910000 },
101  { -0.000216644186888890480000, -0.000216644186888890050000, -0.000216644186888889530000, -0.000216644186888888090000, -0.000216644186888884950000, -0.000216644186888879640000, -0.000216644186888872860000, -0.000216644186888866840000, -0.000216644186888864430000, -0.000216644186888866840000, -0.000216644186888872860000, -0.000216644186888879640000, -0.000216644186888884950000, -0.000216644186888888090000, -0.000216644186888889530000, -0.000216644186888890050000, -0.000216644186888889940000 },
102  { 0.000150241317361506390000, 0.00140024804414172520000, 0.00563051421821006860000, 0.0171342518828273840000, 0.0420319459852840780000, 0.0841976119531329250000, 0.13818225578280030000, 0.185976095591570160000, 0.205327974259260050000, 0.185976095591570160000, 0.13818225578280030000, 0.0841976119531328840000, 0.0420319459852840780000, 0.0171342518828273840000, 0.00563051421821006860000, 0.00140024804414172520000, 0.000150241317361506390000 },
103  { -0.000216644186888889750000, -0.000216644186888887990000, -0.000216644186888882020000, -0.000216644186888865840000, -0.000216644186888830790000, -0.000216644186888921240000, -0.000216644186888941060000, -0.000216644186888958590000, -0.00021664418688896570000, -0.000216644186888958590000, -0.000216644186888941060000, -0.000216644186888921240000, -0.000216644186888980740000, -0.000216644186888927420000, -0.000216644186888902790000, -0.000216644186888893730000, -0.000216644186888891050000 },
104  { -0.00141849613025914810000, -0.00551329681440222190000, -0.0193708996997089270000, -0.0570551071924256320000, -0.138615544156578060000, -0.276742799117225710000, -0.453586932633484150000, -0.610151088452771220000, -0.673544416112713430000, -0.610151088452771220000, -0.453586932633484150000, -0.276742799117225710000, -0.138615544156578060000, -0.0570551071924256320000, -0.0193708996997089270000, -0.00551329681440222190000, -0.00141849613025914810000 },
105  { -0.000216644186888891240000, -0.000216644186888894570000, -0.000216644186888905850000, -0.000216644186888919540000, -0.000216644186888961550000, -0.00021664418688903270000, -0.000216644186889123770000, -0.000216644186888840010000, -0.000216644186888834810000, -0.000216644186888657810000, -0.00021664418688871750000, -0.000216644186888702260000, -0.000216644186888796180000, -0.000216644186888851610000, -0.000216644186888877250000, -0.000216644186888885090000, -0.00021664418688888910000 },
106  { 0.00156829918464733840000, 0.00764973656904527170000, 0.0282305049007476050000, 0.0841976119531329250000, 0.205327974259260050000, 0.410469156191473670000, 0.673111127738935560000, 0.905634071759926610000, 0.999783355813111060000, 0.905634071759926610000, 0.673111127738935560000, 0.410469156191473670000, 0.205327974259260050000, 0.0841976119531329250000, 0.0282305049007476050000, 0.00764973656904527170000, 0.00156829918464733840000 },
107  { -0.00021664418688888910000, -0.000216644186888885090000, -0.000216644186888877250000, -0.000216644186888851610000, -0.000216644186888796180000, -0.000216644186888702260000, -0.00021664418688871750000, -0.000216644186888657810000, -0.000216644186888834810000, -0.000216644186888840010000, -0.000216644186889123770000, -0.00021664418688903270000, -0.000216644186888961550000, -0.000216644186888919540000, -0.000216644186888905850000, -0.000216644186888894570000, -0.000216644186888891240000 },
108  { -0.00141849613025914810000, -0.00551329681440222190000, -0.0193708996997089270000, -0.0570551071924256320000, -0.138615544156578060000, -0.276742799117225710000, -0.453586932633484150000, -0.610151088452771220000, -0.673544416112713430000, -0.610151088452771220000, -0.453586932633484150000, -0.276742799117225710000, -0.138615544156578060000, -0.0570551071924256320000, -0.0193708996997089270000, -0.00551329681440222190000, -0.00141849613025914810000 },
109  { -0.000216644186888891050000, -0.000216644186888893730000, -0.000216644186888902790000, -0.000216644186888927420000, -0.000216644186888980740000, -0.000216644186888921240000, -0.000216644186888941060000, -0.000216644186888958590000, -0.00021664418688896570000, -0.000216644186888958590000, -0.000216644186888941060000, -0.000216644186888921240000, -0.000216644186888830790000, -0.000216644186888865840000, -0.000216644186888882020000, -0.000216644186888887990000, -0.000216644186888889750000 },
110  { 0.000150241317361506390000, 0.00140024804414172520000, 0.00563051421821006860000, 0.0171342518828273840000, 0.0420319459852840780000, 0.0841976119531328840000, 0.13818225578280030000, 0.185976095591570160000, 0.205327974259260050000, 0.185976095591570160000, 0.13818225578280030000, 0.0841976119531329250000, 0.0420319459852840780000, 0.0171342518828273840000, 0.00563051421821006860000, 0.00140024804414172520000, 0.000150241317361506390000 },
111  { -0.000216644186888889940000, -0.000216644186888890050000, -0.000216644186888889530000, -0.000216644186888888090000, -0.000216644186888884950000, -0.000216644186888879640000, -0.000216644186888872860000, -0.000216644186888866840000, -0.000216644186888864430000, -0.000216644186888866840000, -0.000216644186888872860000, -0.000216644186888879640000, -0.000216644186888884950000, -0.000216644186888888090000, -0.000216644186888889530000, -0.000216644186888890050000, -0.000216644186888890480000 },
112  { -0.000267420737091969910000, -0.000440420293033064140000, -0.00102588447810310820000, -0.00261798911642602580000, -0.00606380259198784860000, -0.0118994843784274940000, -0.0193708996997089270000, -0.0259855145545702140000, -0.0286637932745253880000, -0.0259855145545702140000, -0.0193708996997089270000, -0.0118994843784274940000, -0.00606380259198784860000, -0.00261798911642602580000, -0.00102588447810310820000, -0.000440420293033064140000, -0.000267420737091969860000 },
113  { -0.000216644186888890290000, -0.000216644186888890290000, -0.000216644186888890370000, -0.000216644186888890560000, -0.000216644186888890970000, -0.000216644186888891650000, -0.000216644186888892540000, -0.000216644186888893330000, -0.000216644186888893620000, -0.000216644186888893330000, -0.000216644186888892540000, -0.000216644186888891650000, -0.000216644186888890970000, -0.000216644186888890560000, -0.000216644186888890370000, -0.000216644186888890290000, -0.000216644186888890240000 },
114  { -0.000213458164049299130000, -0.000202603142700605470000, -0.00016586763668581070000, -6.59695199285971420000e-005, 0.000150241317361506390000, 0.00051640671028051850000, 0.000985207756481367660000, 0.00140024804414172520000, 0.00156829918464733840000, 0.00140024804414172520000, 0.000985207756481367660000, 0.00051640671028051850000, 0.000150241317361506390000, -6.59695199285968710000e-005, -0.000165867636685810620000, -0.000202603142700605410000, -0.000213458164049299130000 } },
115  { { -0.000212455820116683020000, -0.00020940739692195540000, -0.000246397192665000250000, -0.000363588772779722510000, -0.000313327068380500610000, 0.000330813391145331190000, 0.000899967028943326470000, -8.81425456724336540000e-005, -0.00174750913491093520000, -0.00157541215951787130000, -8.17539241526276080000e-005, 0.000473356818591131050000, 4.97134655875084920000e-005, -0.000260486197811391870000, -0.000265786932032037870000, -0.000223776723112710220000, -0.000214134630995544250000 },
116  { -0.000209407396921955370000, -0.000153761896758942750000, -0.000116281707141741030000, -0.000617847560383966480000, -0.00180326268368728310000, -0.00107580924696983530000, 0.0037327655087010360000, 0.00639879059704402850000, 0.000404658013336228730000, -0.0063310901084227310000, -0.00467000861014637070000, 0.000144252542662051190000, 0.00130408425975803460000, 0.000264630954308319620000, -0.000282242920061493990000, -0.000276752245330172530000, -0.000223776723112710220000 },
117  { -0.000246397192665000140000, -0.000116281707141740450000, 0.000593598448257943110000, 0.000850593343845246510000, -0.00375726491171348270000, -0.0116869818686263640000, -0.00531556469607082690000, 0.0189938484443886170000, 0.0261901829988486730000, 0.00181635064276650320000, -0.0166541339484945930000, -0.0100406499670049570000, 0.000435739447470086680000, 0.00204139576350936610000, 0.000369653036981673640000, -0.000282242920061493990000, -0.000265786932032037870000 },
118  { -0.000363588772779722570000, -0.000617847560383965290000, 0.000850593343845249330000, 0.00691012479671693130000, 0.00748843085585157880000, -0.0212138851397784230000, -0.0560251303734258170000, -0.020575313029809510000, 0.0627112466972920970000, 0.0707639371444771380000, 0.00426632915846320710000, -0.0299680542957719880000, -0.0148073585873103630000, 0.000578178120084199360000, 0.00204139576350936910000, 0.000264630954308319620000, -0.000260486197811391870000 },
119  { -0.000313327068380500990000, -0.00180326268368728360000, -0.00375726491171347230000, 0.00748843085585160220000, 0.042032948329216710000, 0.0372656250325676670000, -0.0840438371584510820000, -0.183037643453210440000, -0.0549429945321079360000, 0.138582356490498380000, 0.128251963105421670000, 0.00644080571244505690000, -0.036474065750403670000, -0.0148073585873103630000, 0.000435739447470086680000, 0.00130408425975803350000, 4.97134655875101180000e-005 },
120  { 0.000330813391145330320000, -0.001075809246969840000, -0.0116869818686263680000, -0.0212138851397783850000, 0.0372656250325677850000, 0.168447184789459910000, 0.122566351210613680000, -0.225548122324692460000, -0.403466596458147590000, -0.0992679611922332730000, 0.205921701841042190000, 0.156344196320753580000, 0.00644080571244505690000, -0.0299680542957719880000, -0.0100406499670049570000, 0.000144252542662045820000, 0.000473356818591130620000 },
121  { 0.000899967028943327330000, 0.00373276550870103340000, -0.00531556469607084080000, -0.0560251303734258590000, -0.0840438371584509430000, 0.122566351210613960000, 0.453154646603639020000, 0.270604912971661280000, -0.408050183798901730000, -0.599108144764422650000, -0.120927903064719770000, 0.205921701841042190000, 0.128251963105421830000, 0.00426632915846320540000, -0.0166541339484946040000, -0.00467000861014637070000, -8.17539241526297220000e-005 },
122  { -8.81425456724279080000e-005, 0.00639879059704404150000, 0.0189938484443885790000, -0.020575313029809510000, -0.183037643453210440000, -0.225548122324692350000, 0.270604912971661450000, 0.820349877738402070000, 0.401996425008270990000, -0.497232067982842470000, -0.599108144764422870000, -0.0992679611922332730000, 0.138582356490498270000, 0.0707639371444771930000, 0.00181635064276655010000, -0.00633109010842272580000, -0.00157541215951787130000 },
123  { -0.00174750913491093520000, 0.000404658013336242610000, 0.0261901829988486910000, 0.0627112466972920560000, -0.0549429945321079360000, -0.403466596458147640000, -0.408050183798901730000, 0.401996425008270990000, 0.99978435815704370000, 0.401996425008270990000, -0.408050183798901730000, -0.403466596458147640000, -0.0549429945321079360000, 0.0627112466972920560000, 0.0261901829988486910000, 0.000404658013336242610000, -0.00174750913491093520000 },
124  { -0.00157541215951787130000, -0.00633109010842272580000, 0.00181635064276655010000, 0.0707639371444771930000, 0.138582356490498270000, -0.0992679611922332730000, -0.599108144764422870000, -0.497232067982842470000, 0.401996425008270990000, 0.820349877738402070000, 0.270604912971661450000, -0.225548122324692350000, -0.183037643453210440000, -0.020575313029809510000, 0.0189938484443885790000, 0.00639879059704404150000, -8.81425456724279080000e-005 },
125  { -8.17539241526297220000e-005, -0.00467000861014637070000, -0.0166541339484946040000, 0.00426632915846320540000, 0.128251963105421830000, 0.205921701841042190000, -0.120927903064719770000, -0.599108144764422650000, -0.408050183798901730000, 0.270604912971661280000, 0.453154646603639020000, 0.122566351210613960000, -0.0840438371584509430000, -0.0560251303734258590000, -0.00531556469607084080000, 0.00373276550870103340000, 0.000899967028943327330000 },
126  { 0.000473356818591130620000, 0.000144252542662045820000, -0.0100406499670049570000, -0.0299680542957719880000, 0.00644080571244505690000, 0.156344196320753580000, 0.205921701841042190000, -0.0992679611922332730000, -0.403466596458147590000, -0.225548122324692460000, 0.122566351210613680000, 0.168447184789459910000, 0.0372656250325677850000, -0.0212138851397783850000, -0.0116869818686263680000, -0.001075809246969840000, 0.000330813391145330320000 },
127  { 4.97134655875101180000e-005, 0.00130408425975803350000, 0.000435739447470086680000, -0.0148073585873103630000, -0.036474065750403670000, 0.00644080571244505690000, 0.128251963105421670000, 0.138582356490498380000, -0.0549429945321079360000, -0.183037643453210440000, -0.0840438371584510820000, 0.0372656250325676670000, 0.042032948329216710000, 0.00748843085585160220000, -0.00375726491171347230000, -0.00180326268368728360000, -0.000313327068380500990000 },
128  { -0.000260486197811391870000, 0.000264630954308319620000, 0.00204139576350936910000, 0.000578178120084199360000, -0.0148073585873103630000, -0.0299680542957719880000, 0.00426632915846320710000, 0.0707639371444771380000, 0.0627112466972920970000, -0.020575313029809510000, -0.0560251303734258170000, -0.0212138851397784230000, 0.00748843085585157880000, 0.00691012479671693130000, 0.000850593343845249330000, -0.000617847560383965290000, -0.000363588772779722570000 },
129  { -0.000265786932032037870000, -0.000282242920061493990000, 0.000369653036981673640000, 0.00204139576350936610000, 0.000435739447470086680000, -0.0100406499670049570000, -0.0166541339484945930000, 0.00181635064276650320000, 0.0261901829988486730000, 0.0189938484443886170000, -0.00531556469607082690000, -0.0116869818686263640000, -0.00375726491171348270000, 0.000850593343845246510000, 0.000593598448257943110000, -0.000116281707141740450000, -0.000246397192665000140000 },
130  { -0.000223776723112710220000, -0.000276752245330172530000, -0.000282242920061493990000, 0.000264630954308319620000, 0.00130408425975803460000, 0.000144252542662051190000, -0.00467000861014637070000, -0.0063310901084227310000, 0.000404658013336228730000, 0.00639879059704402850000, 0.0037327655087010360000, -0.00107580924696983530000, -0.00180326268368728310000, -0.000617847560383966480000, -0.000116281707141741030000, -0.000153761896758942750000, -0.000209407396921955370000 },
131  { -0.000214134630995544250000, -0.000223776723112710220000, -0.000265786932032037870000, -0.000260486197811391870000, 4.97134655875084920000e-005, 0.000473356818591131050000, -8.17539241526276080000e-005, -0.00157541215951787130000, -0.00174750913491093520000, -8.81425456724336540000e-005, 0.000899967028943326470000, 0.000330813391145331190000, -0.000313327068380500610000, -0.000363588772779722510000, -0.000246397192665000250000, -0.00020940739692195540000, -0.000212455820116683020000 } } };
132 
133  const size_t orientations = sizeof( gabor::GABOR_KERNELS ) / sizeof( gabor::GABOR_KERNELS[ 0 ] );
134 
135  template< class T1, class T2 >
136  bool filter( const mist::array2< T1 >& in, const size_t theta, mist::array2< T2 >& out )
137  {
138  if( in.empty( ) || orientations <= theta )
139  {
140  return false;
141  }
142 
143  const int kernel_width = sizeof( GABOR_KERNELS[ theta ] ) / sizeof( GABOR_KERNELS[ theta ][ 0 ] );
144  const int kernel_height = sizeof( GABOR_KERNELS[ theta ][ 0 ] ) / sizeof( GABOR_KERNELS[ theta ][ 0 ][ 0 ] );
145  kernel_type gabor_kernel( kernel_width, kernel_height, GABOR_KERNELS[ theta ][ 0 ], kernel_width * kernel_height );
146 
147  out.resize( in.width( ), in.height( ) );
148  out.fill( static_cast< T2 >( 0 ) );
149 
150  // mist::linear_filterとほぼ同等の処理(だけど端の部分にノイズが発生するため不使用)
151  for( int x = 0; x < static_cast< int >( in.width( ) ); ++x )
152  {
153  for( int y = 0; y < static_cast< int >( in.height( ) ); ++y )
154  {
155  for( int i = - kernel_width / 2; i <= kernel_width / 2; ++i )
156  {
157  for( int j = - kernel_height / 2; j <= kernel_height / 2; ++j )
158  {
159  if( 0 <= x + i && x + i < static_cast< int >( in.width( ) ) && 0 <= y + j && y + j < static_cast< int >( in.height( ) ) )
160  {
161  out( x, y ) += in( x + i, y + j ) * gabor_kernel( i + kernel_width / 2, j + kernel_height / 2 );
162  }
163  }
164  }
165  }
166  }
167 
168  return true;
169  }
170 }
171 
172 // IttiらのSaliency map関連のアルゴリズム
173 namespace __itti__
174 {
175 
176  typedef double value_type;
177  typedef mist::array2< value_type > map_type;
178  typedef mist::array< map_type > pyramid_type;
179  typedef mist::array< map_type > maps_type;
180 
181  // ガウシアンピラミッドを作成
182  inline bool build_gaussian_pyramid( const map_type& in, const double gauss_sigma, const size_t scale_offset, const size_t pyramid_scales, pyramid_type& out_pyr )
183  {
184  if( scale_offset >= pyramid_scales || pyramid_scales == 0 )
185  {
186  return false;
187  }
188 
189  out_pyr.resize( pyramid_scales );
190 
191  // スケール0 〜 スケールscale_min_c-1 はスキップ(要素だけは確保しておく)
192  // スケールscale_min_c 〜 スケールpyramid_scales-1 を格納
193  map_type temp1, temp2;
194  for( pyramid_type::size_type l = 1; l < out_pyr.size( ); ++l )
195  {
196  const map_type& src_map = ( l == 1 ? in : ( l <= scale_offset ? temp1 : out_pyr[ l - 1 ] ) );
197  map_type& dst_map = ( l < scale_offset ? temp1 : out_pyr[ l ] );
198  if( !mist::gaussian_filter( src_map, temp2, gauss_sigma )
199  || !mist::nearest::interpolate( temp2, dst_map, src_map.width( ) / 2 + ( src_map.width( ) % 2 ), src_map.height( ) / 2 + ( src_map.height( ) % 2 ) ) )
200  {
201  return false;
202  }
203  }
204 
205  return true;
206  }
207 
208  // Center-Surround difference
209  inline bool across_scale_difference( const pyramid_type& in1_pyr, const pyramid_type& in2_pyr, const size_t scale_min_c, const size_t scale_max_c, const size_t scale_min_d, const size_t scale_max_d, maps_type& out_fms )
210  {
211  out_fms.resize( ( scale_max_c - scale_min_c + 1 ) * ( scale_max_d - scale_min_d + 1 ) );
212  if( out_fms.empty( ) )
213  {
214  return false;
215  }
216 
217  size_t level = 0;
218  for( size_t c = scale_min_c; c <= scale_max_c; ++c )
219  {
220  for( size_t d = scale_min_d; d <= scale_max_d; ++d )
221  {
222  const size_t s = c + d;
223  const map_type& center = in1_pyr[ c ];
224  const map_type& surround = in2_pyr[ s ];
225 
226  // スケール間差分
227  map_type ex_surround;
228  mist::linear::interpolate( surround, ex_surround, center.width( ), center.height( ) );
229  out_fms[ level ].resize( ex_surround.width( ), ex_surround.height( ) );
230  for( size_t i = 0; i < center.size( ); ++i )
231  {
232  out_fms[ level ][ i ] = std::fabs( center[ i ] - ex_surround[ i ] );
233  }
234  ++level;
235  }
236  }
237 
238  return true;
239  }
240 
241  // Center-Surround addition
242  inline bool across_scale_addition( const maps_type& in_fms, const map_type::size_type base_width, const map_type::size_type base_height, map_type& out_fm )
243  {
244  if( in_fms.empty( )
245  || base_width == 0
246  || base_height == 0 )
247  {
248  return false;
249  }
250 
251  out_fm.resize( base_width, base_height );
252  out_fm.fill( 0 );
253 
254  // 各Feature mapをTARGET_SCALEに縮小してからスケール間差分
255  for( maps_type::size_type l = 0; l < in_fms.size( ); ++l )
256  {
257  map_type target_scale_in_fms;
258  mist::linear::interpolate( in_fms[ l ], target_scale_in_fms, base_width, base_height ); // interpolateのアルゴリズムは何が良いんだろう?(meanよりlinearの方が,Saliency mapにおけるピークが強く出る傾向があるっぽい)
259  for( map_type::size_type i = 0; i < target_scale_in_fms.size( ); ++i )
260  {
261  out_fm[ i ] += target_scale_in_fms[ i ];
262  }
263  }
264 
265  return true;
266  }
267 
268  // 画像の画素値に関する正規化
269  template< class T1, class T2 >
270  inline bool normalize( const mist::array2< T1 >& in, mist::array2< T2 >& out, const T2 out_min = 0.0, const T2 out_max = 1.0 )
271  {
272  typedef typename mist::array2< T1 >::size_type size_type;
273 
274  if( in.empty( ) || out_min > out_max )
275  {
276  return false;
277  }
278 
279  T1 in_min = in[ 0 ];
280  T1 in_max = in[ 0 ];
281  for( size_type i = 1; i < in.size( ); ++i )
282  {
283  const T1 val = in[ i ];
284  if( in_max < val )
285  {
286  in_max = val;
287  }
288  else if( in_min > val )
289  {
290  in_min = val;
291  }
292  }
293 
294  out.resize( in.width( ), in.height( ) );
295  const T1 in_range = in_max - in_min;
296  const T2 out_range = out_max - out_min;
297  for( size_type i = 0; i < in.size( ); ++i )
298  {
299  out[ i ] = static_cast< T2 >( ( in[ i ] - in_min ) / in_range ) * out_range + out_min;
300  }
301 
302  return true;
303  }
304 
305  // 最大値・極大値を考慮した正規化(関数N)
306  inline bool normalize_map_with_local_maxima( const map_type& in, const size_t step_local_maxima, map_type& out )
307  {
308  const value_type global_max = 1.0;
309  if( !normalize( in, out, 0.0, global_max ) )
310  {
311  return false;
312  }
313 
314  size_t local_maxima_count = 0;
315  value_type local_maxima_sum = 0;
316 
317  // ±step_local_maximaの範囲の最大値を極大値とする
318  for( map_type::size_type x = 0; x < out.width( ) - step_local_maxima; x += step_local_maxima )
319  {
320  for( map_type::size_type y = 0; y < out.height( ) - step_local_maxima; y += step_local_maxima )
321  {
322  value_type local_max = 0;
323  for( map_type::size_type i = 0; i < step_local_maxima; ++i )
324  {
325  for( map_type::size_type j = 0; j < step_local_maxima; ++j )
326  {
327  if( local_max < out( x + i, y + j ) )
328  {
329  local_max = out( x + i, y + j );
330  }
331  }
332  }
333  if( global_max != local_max )
334  {
335  local_maxima_sum += local_max;
336  ++local_maxima_count;
337  }
338  }
339  }
340 
341  const value_type normalize_factor = std::pow( global_max - local_maxima_sum / local_maxima_count, 2.0 );
342  for( map_type::size_type i = 0; i < out.size( ); ++i )
343  {
344  out[ i ] *= normalize_factor;
345  }
346 
347  return true;
348  }
349 
350  // 最大値・極大値を考慮した正規化(関数N)
351  inline bool normalize_maps_with_local_maxima( const maps_type& in_fms, const size_t step_local_maxima, maps_type& out_fms )
352  {
353  if( in_fms.empty( ) )
354  {
355  return false;
356  }
357 
358  out_fms.resize( in_fms.size( ) );
359  for( maps_type::size_type l = 0; l < in_fms.size( ); ++l )
360  {
361  if( !normalize_map_with_local_maxima( in_fms[ l ], step_local_maxima, out_fms[ l ] ) )
362  {
363  return false;
364  }
365  }
366 
367  return true;
368  }
369 
370  // 特徴抽出
371  template< class T, class Allocator >
372  inline bool create_original_feature_maps( const mist::array2< mist::rgb< T >, Allocator >& in, map_type& i_fm, map_type& rg_fm, map_type& by_fm )
373  {
374  typedef typename mist::array2< mist::rgb< T >, Allocator >::size_type size_type;
375 
376  if( in.empty( ) )
377  {
378  return false;
379  }
380 
381  const size_type w = in.width( );
382  const size_type h = in.height( );
383  const size_type size = in.size( );
384 
385  // Intensity
386  i_fm.resize( w, h );
387  value_type max_i = 0;
388  for( size_type i = 0; i < size; ++i )
389  {
390  i_fm[ i ] = in[ i ].get_average( );
391  if( max_i < i_fm[ i ] )
392  {
393  max_i = i_fm[ i ];
394  }
395  }
396 
397  // Red, Green, Blue, Yellow
398  rg_fm.resize( w, h );
399  by_fm.resize( w, h );
400  for( size_type k = 0; k < size; ++k )
401  {
402  const value_type i = i_fm[ k ];
403  if( max_i > i * 10 )
404  {
405  rg_fm[ k ] = by_fm[ k ] = 0;
406  }
407  else
408  {
409  const value_type r = in[ k ].r / i;
410  const value_type g = in[ k ].g / i;
411  const value_type b = in[ k ].b / i;
412  const value_type R = std::max< value_type >( 0.0, r - ( g + b ) / 2.0 );
413  const value_type G = std::max< value_type >( 0.0, g - ( r + b ) / 2.0 );
414  const value_type B = std::max< value_type >( 0.0, b - ( r + g ) / 2.0 );
415  const value_type Y = std::max< value_type >( 0.0, ( r + g ) / 2.0 - std::abs( r - g ) / 2.0 - b );
416 
417  rg_fm[ k ] = R - G;
418  by_fm[ k ] = B - Y;
419  }
420  }
421 
422  return true;
423  }
424 
425  // Conspicuity mapを作成(Intensity)
426  inline bool conspicuity_map_for_intensity( const map_type& i_image, const size_t step_local_maxima, const double gauss_sigma, const size_t scale_min_c, const size_t scale_max_c, const size_t scale_min_d, const size_t scale_max_d, const size_t base_scale, map_type& i_ncm )
427  {
428  if( scale_min_c > scale_max_c
429  || scale_min_d > scale_max_d
430  || scale_min_c > base_scale
431  || base_scale > scale_max_c + scale_max_d
432  || i_image.empty( ) )
433  {
434  return false;
435  }
436  const pyramid_type::size_type pyramid_size = scale_max_c + scale_max_d + 1;
437 
438  // Intensity feature maps
439  maps_type i_fms;
440  map_type::size_type base_width, base_height;
441  {
442  // ガウシアンピラミッド
443  pyramid_type i_pyr;
444  if( !build_gaussian_pyramid( i_image, gauss_sigma, scale_min_c, pyramid_size, i_pyr ) )
445  {
446  return false;
447  }
448 
449  // Center-Surround difference
450  if( !across_scale_difference( i_pyr, i_pyr, scale_min_c, scale_max_c, scale_min_d, scale_max_d, i_fms ) )
451  {
452  return false;
453  }
454 
455  base_width = i_pyr[ base_scale ].width( );
456  base_height = i_pyr[ base_scale ].height( );
457  }
458 
459  // Conspicuity map
460  map_type i_cm;
461  {
462  pyramid_type i_nfms;
463  if( !normalize_maps_with_local_maxima( i_fms, step_local_maxima, i_nfms ) || !across_scale_addition( i_nfms, base_width, base_height, i_cm ) )
464  {
465  return false;
466  }
467  }
468 
469  // 正規化
470  return normalize_map_with_local_maxima( i_cm, step_local_maxima, i_ncm );
471  }
472 
473  // Conspicuity mapを作成(Color)
474  inline bool conspicuity_map_for_color( const map_type& rg_image, const map_type& by_image, const size_t step_local_maxima, const double gauss_sigma, const size_t scale_min_c, const size_t scale_max_c, const size_t scale_min_d, const size_t scale_max_d, const size_t base_scale, map_type& c_ncm )
475  {
476  if( scale_min_c > scale_max_c
477  || scale_min_d > scale_max_d
478  || scale_min_c > base_scale
479  || base_scale > scale_max_c + scale_max_d
480  || rg_image.empty( )
481  || by_image.empty( ) )
482  {
483  return false;
484  }
485  const pyramid_type::size_type pyramid_size = scale_max_c + scale_max_d + 1;
486 
487  // Red-Green feature maps
488  maps_type rg_fms;
489  map_type::size_type base_width, base_height;
490  {
491  // ガウシアンピラミッド
492  pyramid_type rg_pyr;
493  if( !build_gaussian_pyramid( rg_image, gauss_sigma, scale_min_c, pyramid_size, rg_pyr ) )
494  {
495  return false;
496  }
497 
498  // Center-Surround difference
499  if( !across_scale_difference( rg_pyr, -rg_pyr, scale_min_c, scale_max_c, scale_min_d, scale_max_d, rg_fms ) )
500  {
501  return false;
502  }
503 
504  base_width = rg_pyr[ base_scale ].width( );
505  base_height = rg_pyr[ base_scale ].height( );
506  }
507 
508  // Blue-Yellow feature maps
509  maps_type by_fms;
510  {
511  // ガウシアンピラミッド
512  pyramid_type by_pyr;
513  if( !build_gaussian_pyramid( by_image, gauss_sigma, scale_min_c, pyramid_size, by_pyr ) )
514  {
515  return false;
516  }
517 
518  // Center-Surround difference
519  if( !across_scale_difference( by_pyr, -by_pyr, scale_min_c, scale_max_c, scale_min_d, scale_max_d, by_fms ) )
520  {
521  return false;
522  }
523 
524  if( base_width != by_pyr[ base_scale ].width( ) || base_height != by_pyr[ base_scale ].height( ) )
525  {
526  return false;
527  }
528  }
529 
530  // Conspicuity map
531  map_type c_cm;
532  {
533  pyramid_type rg_nfms, by_nfms;
534  if( !normalize_maps_with_local_maxima( rg_fms, step_local_maxima, rg_nfms )
535  || !normalize_maps_with_local_maxima( by_fms, step_local_maxima, by_nfms ) )
536  {
537  return false;
538  }
539 
540  pyramid_type rg_by_nfms( rg_nfms.size( ) );
541  for( maps_type::size_type l = 0; l < rg_by_nfms.size( ); ++l )
542  {
543  rg_by_nfms[ l ].resize( rg_nfms[ l ].width( ), rg_nfms[ l ].height( ) );
544  for( map_type::size_type i = 0; i < rg_by_nfms[ l ].size( ); ++i )
545  {
546  rg_by_nfms[ l ][ i ] = rg_nfms[ l ][ i ] + by_nfms[ l ][ i ];
547  }
548  }
549 
550  if( !across_scale_addition( rg_by_nfms, base_width, base_height, c_cm ) )
551  {
552  return false;
553  }
554  }
555 
556  // 正規化
557  return normalize_map_with_local_maxima( c_cm, step_local_maxima, c_ncm );
558  }
559 
560  // Conspicuity mapを作成(Orientation)
561  inline bool conspicuity_map_for_orientation( const map_type& i_image, const size_t step_local_maxima, const double gauss_sigma, const size_t scale_min_c, const size_t scale_max_c, const size_t scale_min_d, const size_t scale_max_d, const size_t base_scale, map_type& o_ncm )
562  {
563  if( scale_min_c > scale_max_c
564  || scale_min_d > scale_max_d
565  || scale_min_c > base_scale
566  || base_scale > scale_max_c + scale_max_d
567  || i_image.empty( ) )
568  {
569  return false;
570  }
571  const pyramid_type::size_type pyramid_size = scale_max_c + scale_max_d + 1;
572 
573  // 各方向について
574  maps_type nneo_fms( gabor::orientations );
575  for( maps_type::size_type t = 0; t < nneo_fms.size( ); ++t )
576  {
577  // 各方向成分のOrientation feature maps
578  maps_type o_fms;
579  map_type::size_type base_width, base_height;
580  {
581  // ガウシアンピラミッド
582  pyramid_type o_pyr;
583  {
584  pyramid_type i_pyr;
585  if( !build_gaussian_pyramid( i_image, gauss_sigma, scale_min_c, pyramid_size, i_pyr ) )
586  {
587  return false;
588  }
589 
590  o_pyr.resize( i_pyr.size( ) );
591  for( pyramid_type::size_type l = scale_min_c; l < o_pyr.size( ); ++l )
592  {
593  gabor::filter( i_pyr[ l ], t, o_pyr[ l ] );
594  }
595  }
596 
597  // Center-Surround difference
598  if( !across_scale_difference( o_pyr, o_pyr, scale_min_c, scale_max_c, scale_min_d, scale_max_d, o_fms ) )
599  {
600  return false;
601  }
602 
603  base_width = o_pyr[ base_scale ].width( );
604  base_height = o_pyr[ base_scale ].height( );
605  }
606 
607  // 方向成分毎に統合されたOrientation feature maps
608  maps_type o_nfms;
609  map_type neo_fm;
610  if( !normalize_maps_with_local_maxima( o_fms, step_local_maxima, o_nfms )
611  || !across_scale_addition( o_nfms, base_width, base_height, neo_fm )
612  || !normalize_map_with_local_maxima( neo_fm, step_local_maxima, nneo_fms[ t ] ) )
613  {
614  return false;
615  }
616  }
617 
618  // Conspicuity map
619  map_type o_cm( nneo_fms[ 0 ].width( ), nneo_fms[ 0 ].height( ) );
620  for( maps_type::size_type t = 0; t < nneo_fms.size( ); ++t )
621  {
622  for( map_type::size_type i = 0; i < o_cm.size( ); ++i )
623  {
624  o_cm[ i ] += nneo_fms[ t ][ i ];
625  }
626  }
627 
628  // 正規化
629  return normalize_map_with_local_maxima( o_cm, step_local_maxima, o_ncm );
630  }
631 
632  // Conspicuity mapsを作成
633  template< class T, class Allocator >
634  inline bool create_comspicuity_maps( const mist::array2< mist::rgb< T >, Allocator >& in, map_type& i_cm, map_type& c_cm, map_type& o_cm, const double gauss_sigma = 5, const size_t step_local_maxima = 3, const size_t scale_min_c = 2, const size_t scale_max_c = 4, const size_t scale_min_d = 3, const size_t scale_max_d = 4, const size_t base_scale = 4 )
635  {
636  if( in.empty( ) )
637  {
638  return false;
639  }
640 
641  // 特徴抽出
642  map_type i_image, rg_image, by_image;
643  if( !create_original_feature_maps( in, i_image, rg_image, by_image ) )
644  {
645  return false;
646  }
647 
648  // Conspicuity maps
649  return ( conspicuity_map_for_intensity( i_image, step_local_maxima, gauss_sigma, scale_min_c, scale_max_c, scale_min_d, scale_max_d, base_scale, i_cm )
650  && conspicuity_map_for_color( rg_image, by_image, step_local_maxima, gauss_sigma, scale_min_c, scale_max_c, scale_min_d, scale_max_d, base_scale, c_cm )
651  && conspicuity_map_for_orientation( i_image, step_local_maxima, gauss_sigma, scale_min_c, scale_max_c, scale_min_d, scale_max_d, base_scale, o_cm ) );
652  }
653 
654 } // 名前空間 __itti__ の終わり
655 
656 namespace itti
657 {
664 
685  template< class T1, class Allocator1, class T2, class Allocator2 >
686  bool saliency_map( const mist::array2< mist::rgb< T1 >, Allocator1 >& in, __itti__::map_type& i_cm, __itti__::map_type& c_cm, __itti__::map_type& o_cm, mist::array2< T2, Allocator2 >& sm, const double intensity_weight = 1.0, const double color_weight = 1.0, const double orientation_weight = 1.0, const double gauss_sigma = 5, const size_t step_local_maxima = 3, const size_t scale_min_c = 2, const size_t scale_max_c = 4, const size_t scale_min_d = 3, const size_t scale_max_d = 4, const size_t base_scale = 4 )
687  {
688  if( !__itti__::create_comspicuity_maps( in, i_cm, c_cm, o_cm, gauss_sigma, step_local_maxima, scale_min_c, scale_max_c, scale_min_d, scale_max_d, base_scale ) )
689  {
690  return false;
691  }
692 
693  // Saliency map
694  __itti__::map_type temp_sm( i_cm.width( ), i_cm.height( ) );
695  for( __itti__::map_type::size_type i = 0; i < temp_sm.size( ); ++i )
696  {
697  temp_sm[ i ] = intensity_weight * i_cm[ i ] + color_weight * c_cm[ i ] + orientation_weight * o_cm[ i ];
698  }
699  if( !__itti__::normalize( temp_sm, sm, static_cast< T2 >( 0 ), static_cast< T2 >( 255 ) ) )
700  {
701  return false;
702  }
703 
704  // Conspicuity maps
705  __itti__::map_type temp;
706  return ( __itti__::normalize( i_cm, temp, __itti__::map_type::value_type( 0 ), __itti__::map_type::value_type( 255 ) )
707  && mist::linear::interpolate( temp, i_cm, in.width( ), in.height( ) )
708  && __itti__::normalize( c_cm, temp, __itti__::map_type::value_type( 0 ), __itti__::map_type::value_type( 255 ) )
709  && mist::linear::interpolate( temp, c_cm, in.width( ), in.height( ) )
710  && __itti__::normalize( o_cm, temp, __itti__::map_type::value_type( 0 ), __itti__::map_type::value_type( 255 ) )
711  && mist::linear::interpolate( temp, o_cm, in.width( ), in.height( ) ) );
712  }
713 
731  template< class T1, class Allocator1, class T2, class Allocator2 >
732  bool saliency_map( const mist::array2< mist::rgb< T1 >, Allocator1 >& in, mist::array2< T2, Allocator2 >& sm, const double intensity_weight = 1.0, const double color_weight = 1.0, const double orientation_weight = 1.0, const double gauss_sigma = 5, const size_t step_local_maxima = 3, const size_t scale_min_c = 2, const size_t scale_max_c = 4, const size_t scale_min_d = 3, const size_t scale_max_d = 4, const size_t base_scale = 4 )
733  {
734  mist::__itti__::map_type i_cm, c_cm, o_cm;
735  if( !__itti__::create_comspicuity_maps( in, i_cm, c_cm, o_cm, gauss_sigma, step_local_maxima, scale_min_c, scale_max_c, scale_min_d, scale_max_d, base_scale ) )
736  {
737  return false;
738  }
739 
740  // Saliency map
741  __itti__::map_type temp_sm( i_cm.width( ), i_cm.height( ) );
742  for( __itti__::map_type::size_type i = 0; i < temp_sm.size( ); ++i )
743  {
744  temp_sm[ i ] = intensity_weight * i_cm[ i ] + color_weight * c_cm[ i ] + orientation_weight * o_cm[ i ];
745  }
746  return __itti__::normalize( temp_sm, sm, static_cast< T2 >( 0 ), static_cast< T2 >( 255 ) );
747  }
748 
749 } // 名前空間 itti の終わり
750 
751 
752 // mist名前空間の終わり
753 _MIST_END
754 
755 
756 #endif // __INCLUDE_MIST_SALIENCY_MAP__
757 

Generated on Wed Nov 12 2014 19:44:22 for MIST by doxygen 1.8.1.2