1
2 ///////////////////////////////////////////////////////////
3 // //
4 // SAGA //
5 // //
6 // System for Automated Geoscientific Analyses //
7 // //
8 // Tool Library //
9 // imagery_tools //
10 // //
11 //-------------------------------------------------------//
12 // //
13 // tasseled_cap.cpp //
14 // //
15 // Copyright (C) 2011 by //
16 // Olaf Conrad //
17 // //
18 //-------------------------------------------------------//
19 // //
20 // This file is part of 'SAGA - System for Automated //
21 // Geoscientific Analyses'. SAGA is free software; you //
22 // can redistribute it and/or modify it under the terms //
23 // of the GNU General Public License as published by the //
24 // Free Software Foundation, either version 2 of the //
25 // License, or (at your option) any later version. //
26 // //
27 // SAGA is distributed in the hope that it will be //
28 // useful, but WITHOUT ANY WARRANTY; without even the //
29 // implied warranty of MERCHANTABILITY or FITNESS FOR A //
30 // PARTICULAR PURPOSE. See the GNU General Public //
31 // License for more details. //
32 // //
33 // You should have received a copy of the GNU General //
34 // Public License along with this program; if not, see //
35 // <http://www.gnu.org/licenses/>. //
36 // //
37 //-------------------------------------------------------//
38 // //
39 // e-mail: oconrad@saga-gis.org //
40 // //
41 // contact: Olaf Conrad //
42 // Institute of Geography //
43 // University of Hamburg //
44 // Germany //
45 // //
46 ///////////////////////////////////////////////////////////
47
48 //---------------------------------------------------------
49 #include "tasseled_cap.h"
50
51
52 ///////////////////////////////////////////////////////////
53 // //
54 // //
55 // //
56 ///////////////////////////////////////////////////////////
57
58 //---------------------------------------------------------
CTasseled_Cap(void)59 CTasseled_Cap::CTasseled_Cap(void)
60 {
61 Set_Name (_TL("Tasseled Cap Transformation"));
62
63 Set_Author ("O.Conrad (c) 2011");
64
65 Set_Description (_TW(
66 "Tasseled Cap Transformation as proposed for Landsat Thematic Mapper."
67 ));
68
69 Add_Reference(
70 "Kauth, R.J., Thomas, G.S.", "1976",
71 "The Tasseled Cap - A Graphic Description of the Spectral-Temporal Development of Agricultural Crops as Seen by LANDSAT",
72 "Proceedings of the Symposium on Machine Processing of Remotely Sensed Data.",
73 SG_T("http://docs.lib.purdue.edu/cgi/viewcontent.cgi?article=1160&context=lars_symp")
74 );
75
76 Add_Reference(
77 "Huang, C., Wylie, B., Yang, L., Homer, C., Zylstra, G.", "2002",
78 "Derivation of a tasselled cap transformation based on Landsat 7 at-satellite reflectance",
79 "International Journal of Remote Sensing, 23(8), 1741-1748.",
80 SG_T("http://www.tandfonline.com/doi/pdf/10.1080/01431160110106113")
81 );
82
83 Parameters.Add_Grid("", "BLUE" , _TL("Blue (TM 1)" ), _TL(""), PARAMETER_INPUT);
84 Parameters.Add_Grid("", "GREEN" , _TL("Green (TM 2)" ), _TL(""), PARAMETER_INPUT);
85 Parameters.Add_Grid("", "RED" , _TL("Red (TM 3)" ), _TL(""), PARAMETER_INPUT);
86 Parameters.Add_Grid("", "NIR" , _TL("Near Infrared (TM 4)"), _TL(""), PARAMETER_INPUT);
87 Parameters.Add_Grid("", "MIR1" , _TL("Mid Infrared (TM 5)" ), _TL(""), PARAMETER_INPUT);
88 Parameters.Add_Grid("", "MIR2" , _TL("Mid Infrared (TM 7)" ), _TL(""), PARAMETER_INPUT);
89
90 Parameters.Add_Grid("", "BRIGHTNESS", _TL("Brightness" ), _TL(""), PARAMETER_OUTPUT);
91 Parameters.Add_Grid("", "GREENNESS" , _TL("Greenness" ), _TL(""), PARAMETER_OUTPUT);
92 Parameters.Add_Grid("", "WETNESS" , _TL("Wetness" ), _TL(""), PARAMETER_OUTPUT);
93 }
94
95
96 ///////////////////////////////////////////////////////////
97 // //
98 ///////////////////////////////////////////////////////////
99
100 //---------------------------------------------------------
On_Execute(void)101 bool CTasseled_Cap::On_Execute(void)
102 {
103 CSG_Grid *pBand[6], *pBright, *pGreen, *pWet;
104
105 pBand[0] = Parameters("BLUE" )->asGrid();
106 pBand[1] = Parameters("GREEN" )->asGrid();
107 pBand[2] = Parameters("RED" )->asGrid();
108 pBand[3] = Parameters("NIR" )->asGrid();
109 pBand[4] = Parameters("MIR1" )->asGrid();
110 pBand[5] = Parameters("MIR2" )->asGrid();
111
112 pBright = Parameters("BRIGHTNESS")->asGrid();
113 pGreen = Parameters("GREENNESS" )->asGrid();
114 pWet = Parameters("WETNESS" )->asGrid();
115
116 DataObject_Set_Colors(pBright, 11, SG_COLORS_BLACK_WHITE , false);
117 DataObject_Set_Colors(pGreen , 11, SG_COLORS_RED_GREY_GREEN, false);
118 DataObject_Set_Colors(pWet , 11, SG_COLORS_RED_GREY_BLUE , false);
119
120 for(int y=0; y<Get_NY() && Set_Progress(y); y++)
121 {
122 #pragma omp parallel for
123 for(int x=0; x<Get_NX(); x++)
124 {
125 if( pBand[0]->is_NoData(x, y)
126 || pBand[1]->is_NoData(x, y)
127 || pBand[2]->is_NoData(x, y)
128 || pBand[3]->is_NoData(x, y)
129 || pBand[4]->is_NoData(x, y)
130 || pBand[5]->is_NoData(x, y)
131 )
132 {
133 pBright ->Set_NoData(x, y);
134 pGreen ->Set_NoData(x, y);
135 pWet ->Set_NoData(x, y);
136 }
137 else
138 {
139 double b[6];
140
141 b[0] = pBand[0]->asDouble(x, y);
142 b[1] = pBand[1]->asDouble(x, y);
143 b[2] = pBand[2]->asDouble(x, y);
144 b[3] = pBand[3]->asDouble(x, y);
145 b[4] = pBand[4]->asDouble(x, y);
146 b[5] = pBand[5]->asDouble(x, y);
147
148 pBright->Set_Value(x, y,
149 0.3037 * b[0] + 0.2793 * b[1] + 0.4743 * b[2] + 0.5585 * b[3] + 0.5082 * b[4] + 0.1863 * b[5]
150 );
151
152 pGreen ->Set_Value(x, y,
153 -0.2848 * b[0] - 0.2435 * b[1] - 0.5436 * b[2] + 0.7243 * b[3] + 0.0840 * b[4] - 0.1800 * b[5]
154 );
155
156 pWet ->Set_Value(x, y,
157 0.1509 * b[0] + 0.1973 * b[1] + 0.3279 * b[2] + 0.3406 * b[3] - 0.7112 * b[4] - 0.4572 * b[5]
158 );
159 }
160 }
161 }
162
163 return( true );
164 }
165
166
167 ///////////////////////////////////////////////////////////
168 // //
169 // //
170 // //
171 ///////////////////////////////////////////////////////////
172
173 //---------------------------------------------------------
174