Revision 43864 branches/org.gvsig.desktop-2018a/org.gvsig.desktop.library/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.buffer.impl/src/main/java/org/gvsig/raster/lib/buffer/impl/operations/linearstretchenhancement/LinearStretchEnhancementOperation.java
LinearStretchEnhancementOperation.java | ||
---|---|---|
60 | 60 |
* |
61 | 61 |
*/ |
62 | 62 |
public LinearStretchEnhancementOperation(OperationFactory factory) { |
63 |
this.factory = factory;
|
|
63 |
super(factory);
|
|
64 | 64 |
} |
65 | 65 |
|
66 | 66 |
@Override |
... | ... | |
68 | 68 |
super.preProcess(); |
69 | 69 |
BufferManager manager = BufferLocator.getBufferManager(); |
70 | 70 |
|
71 |
if(this.parameters.getDynClass().getDynField(STATISTICS_PARAM)!=null) { |
|
72 |
statistics = (Statistics) this.parameters.getDynValue(STATISTICS_PARAM); |
|
73 |
} |
|
71 |
statistics = (Statistics) this.getParameter(STATISTICS_PARAM, null); |
|
74 | 72 |
if (statistics == null) { |
75 |
statistics = this.buffer.getStatistics(null); |
|
76 |
}; |
|
77 |
if(this.parameters.getDynClass().getDynField(REMOVE_ENDS_PARAM)!=null) { |
|
78 |
removeEnds = (Boolean)this.parameters.getDynValue(REMOVE_ENDS_PARAM); |
|
79 |
} else { |
|
80 |
removeEnds = false; |
|
81 |
}; |
|
82 |
if(this.parameters.getDynClass().getDynField(TAIL_TRIM_PARAM)!=null) { |
|
83 |
tailTrim = (Boolean)this.parameters.getDynValue(TAIL_TRIM_PARAM); |
|
84 |
} else { |
|
85 |
tailTrim = false; |
|
86 |
}; |
|
87 |
if(this.parameters.getDynClass().getDynField(TAIL_TRIM_PERCENT_PARAM)!=null) { |
|
88 |
tailTrimPercent = (Double)this.parameters.getDynValue(TAIL_TRIM_PERCENT_PARAM); |
|
89 |
tailTrimPercent = (tailTrimPercent>100)?100:tailTrimPercent; |
|
90 |
tailTrimPercent = (tailTrimPercent<0)?0:tailTrimPercent; |
|
91 |
} else { |
|
92 |
tailTrimPercent = 0; // FIXME: ?0 o 100? |
|
93 |
}; |
|
73 |
statistics = this.getInputBuffer().getStatistics(null); |
|
74 |
} |
|
75 |
removeEnds = (boolean) this.getParameter(REMOVE_ENDS_PARAM, false); |
|
76 |
tailTrim = (boolean) this.getParameter(TAIL_TRIM_PARAM, false); |
|
77 |
tailTrimPercent = (double) this.getParameter(TAIL_TRIM_PERCENT_PARAM, 0); |
|
78 |
tailTrimPercent = (tailTrimPercent>100)?100:tailTrimPercent; |
|
79 |
tailTrimPercent = (tailTrimPercent<0)?0:tailTrimPercent; |
|
94 | 80 |
|
95 |
int bands = this.buffer.getBandCount();
|
|
81 |
int bands = this.getInputBuffer().getBandCount();
|
|
96 | 82 |
rowProcessors = new RowProcessor[bands]; |
97 | 83 |
int [] bandTypes = new int[bands]; |
98 | 84 |
//FIXME: Falta la gesti?n del par?metro copyUnprocessedBands, de momento se copian sin tenerlo en cuenta |
99 | 85 |
for (int i = 0; i < bandTypes.length; i++) { |
100 |
if(bandsToProcess.contains(i)){
|
|
86 |
if(this.getBandsToProcess().contains(i)){
|
|
101 | 87 |
bandTypes[i] = BufferManager.TYPE_BYTE; |
102 | 88 |
} else { |
103 |
bandTypes[i] = this.buffer.getBandTypes()[i];
|
|
89 |
bandTypes[i] = this.getInputBuffer().getBandTypes()[i];
|
|
104 | 90 |
} |
105 | 91 |
} |
106 |
NoData[] noData = this.buffer.getBandNoData();
|
|
92 |
NoData[] noData = this.getInputBuffer().getBandNoData();
|
|
107 | 93 |
NoData[] resultNoData = new NoData[noData.length]; |
108 | 94 |
for (int band = 0; band < noData.length; band++) { |
109 |
int bandType = this.buffer.getBand(band).getDataType();
|
|
95 |
int bandType = this.getInputBuffer().getBand(band).getDataType();
|
|
110 | 96 |
switch (bandType) { |
111 | 97 |
case BufferManager.TYPE_BYTE: |
112 | 98 |
rowProcessors[band] = new ByteRowProcessor(band); |
... | ... | |
139 | 125 |
} |
140 | 126 |
|
141 | 127 |
try { |
142 |
this.outputBuffer = manager.createBuffer(
|
|
143 |
this.buffer.getRows(),
|
|
144 |
this.buffer.getColumns(),
|
|
128 |
this.setOutputBuffer( manager.createBuffer(
|
|
129 |
this.getInputBuffer().getRows(),
|
|
130 |
this.getInputBuffer().getColumns(),
|
|
145 | 131 |
bandTypes, |
146 | 132 |
resultNoData, |
147 |
this.buffer.getProjection(),
|
|
148 |
this.buffer.getEnvelope());
|
|
133 |
this.getInputBuffer().getProjection(),
|
|
134 |
this.getInputBuffer().getEnvelope()));
|
|
149 | 135 |
} catch (LocatorException | BufferException | CreateEnvelopeException e) { |
150 | 136 |
throw new ProcessingOperationException(e); |
151 | 137 |
} |
... | ... | |
154 | 140 |
@Override |
155 | 141 |
public void process() throws ProcessingOperationException { |
156 | 142 |
super.process(); |
157 |
for (int band=0; band<this.buffer.getBandCount(); band++){
|
|
158 |
if (bandsToProcess.contains(band)) {
|
|
159 |
Band bufferBand = this.buffer.getBand(band);
|
|
160 |
Band outputBufferBand = this.outputBuffer.getBand(band);
|
|
143 |
for (int band=0; band<this.getInputBuffer().getBandCount(); band++){
|
|
144 |
if (this.getBandsToProcess().contains(band)) {
|
|
145 |
Band bufferBand = this.getInputBuffer().getBand(band);
|
|
146 |
Band outputBufferBand = this.getOutputBuffer().getBand(band);
|
|
161 | 147 |
|
162 |
for (int row = 0; row < this.buffer.getRows(); row++) {
|
|
148 |
for (int row = 0; row < this.getInputBuffer().getRows(); row++) {
|
|
163 | 149 |
Object rowBuffer = bufferBand.createRowBuffer(); |
164 | 150 |
bufferBand.fetchRow(row, rowBuffer); |
165 | 151 |
|
... | ... | |
172 | 158 |
} |
173 | 159 |
} else { |
174 | 160 |
try { |
175 |
this.outputBuffer.getBand(band).copyFrom(this.buffer.getBand(band));
|
|
161 |
this.getOutputBuffer().getBand(band).copyFrom(this.getInputBuffer().getBand(band));
|
|
176 | 162 |
} catch (BandException e) { |
177 | 163 |
throw new ProcessingOperationException(e); |
178 | 164 |
} |
... | ... | |
185 | 171 |
super.postProcess(); |
186 | 172 |
} |
187 | 173 |
|
188 |
|
|
189 | 174 |
interface RowProcessor { |
190 | 175 |
void processRow(Object inputRow, Object outputRow); |
191 | 176 |
byte processValue(Object value); |
... | ... | |
201 | 186 |
|
202 | 187 |
public AbstractRowProcessor(int band) { |
203 | 188 |
this.band = band; |
204 |
noData = buffer.getBand(band).getNoData();
|
|
189 |
noData = getInputBuffer().getBand(band).getNoData();
|
|
205 | 190 |
if(noData.isDefined()) { |
206 | 191 |
minResult = (byte)1; |
207 | 192 |
} |
... | ... | |
244 | 229 |
return (byte)0; |
245 | 230 |
} |
246 | 231 |
|
247 |
int iValue = 0xFF & ((Byte) value).byteValue();
|
|
232 |
int iValue = 0xFF & ((Byte) value); |
|
248 | 233 |
Double dValue = new Double(iValue); |
249 | 234 |
|
250 | 235 |
double result; |
... | ... | |
284 | 269 |
return (byte)0; |
285 | 270 |
} |
286 | 271 |
|
287 |
int iValue = ((Short) value).shortValue();
|
|
272 |
int iValue = ((Short) value); |
|
288 | 273 |
Double dValue = ((Number) iValue).doubleValue(); |
289 | 274 |
|
290 | 275 |
double result; |
... | ... | |
324 | 309 |
} |
325 | 310 |
|
326 | 311 |
//FIXME ???: |
327 |
int iValue = 0xFFFF & ((Short) value).shortValue();
|
|
312 |
int iValue = 0xFFFF & ((Short) value); |
|
328 | 313 |
Double dValue = ((Number) iValue).doubleValue(); |
329 | 314 |
|
330 | 315 |
double result; |
Also available in: Unified diff