Revision 20750 trunk/extensions/extRemoteSensing/src/org/gvsig/remotesensing/mosaic/process/MosaicProcess.java

View differences:

MosaicProcess.java
152 152
				bufferFactory.setDrawableBands(((FLyrRasterSE)layers.getLayer(i)).getRenderBands());
153 153
				bufferFactory.setAreaOfInterest(minX,minY,maxX,maxY,fullExtend.getNX(),fullExtend.getNY());
154 154
				buffers[i]= (RasterBuffer) bufferFactory.getRasterBuf();
155
				percent=(int)i*100/layers.getLayersCount();
155
				percent=(int)(i*100/layers.getLayersCount());
156 156
			}
157 157
		}catch (RasterDriverException e) {
158 158
			RasterToolsUtil.messageBoxError(PluginServices.getText(this, "error_writer"), this, e);	
......
165 165
	    
166 166
// 		Construccion del mosaico: Operaci?n M?ximo
167 167
		if(codOp==0){
168
			for(int col=0; col<mosaicGrid.getLayerNY(); col++){
169
				for(int row=0; row<mosaicGrid.getLayerNX();row++){
170
					setValueMax(row,col);
171
					percent= col*100/mosaicGrid.getLayerNY();
168
			int progress = 0;
169
			for(int band=0; band<3; band++){
170
				mosaicGrid.setBandToOperate(band);
171
				for(int col=0; col<mosaicGrid.getLayerNY(); col++){
172
					progress++;
173
					for(int row=0; row<mosaicGrid.getLayerNX();row++){
174
						setValueMax(row,col,band);
175
					}
176
					percent=(int)( progress*100/(mosaicGrid.getLayerNY()*3.));
172 177
				}
173 178
			}
174 179
		}
......
183 188
			}
184 189
		}
185 190
		
186
//		 Construccion del mosaico: Operaci?n Media
191
// 		Construccion del mosaico: Operaci?n Media
187 192
		if(codOp==2){
188
			for(int col=0; col<mosaicGrid.getLayerNY(); col++){
189
				for(int row=0; row<mosaicGrid.getLayerNX();row++){
190
					setValueMax(row,col);
191
					percent= col*100/mosaicGrid.getLayerNY();
193
			int progress = 0;
194
			for(int band=0; band<3; band++){
195
				mosaicGrid.setBandToOperate(band);
196
				for(int col=0; col<mosaicGrid.getLayerNY(); col++){
197
					progress++;
198
					for(int row=0; row<mosaicGrid.getLayerNX();row++){
199
						setValueMean(row,col,band);
200
					}
201
					percent=(int)( progress*100/(mosaicGrid.getLayerNY()*3.));
192 202
				}
193 203
			}
194 204
		}
......
197 207
		if(codOp==3){
198 208
			for(int col=0; col<mosaicGrid.getLayerNY(); col++){
199 209
				for(int row=0; row<mosaicGrid.getLayerNX();row++){
200
					setValueMax(row,col);
210
					//setValueMax(row,col);
201 211
					percent= col*100/mosaicGrid.getLayerNY();
202 212
				}
203 213
			}
......
215 225
	 *  @param cordenada x 
216 226
	 *  @param coordenada y  
217 227
	 * */
218
	public void setValueMax(int x, int y){
219
		byte result[]= new byte[3];
220
		result[0]=(byte) -128;
221
		result[1]=(byte) -128;
222
		result[2]=(byte) -128;
223
		for(int band=0; band<3;band++){
224
			for(int buf=0;buf<buffers.length;buf++){
225
				byte data = (byte)(buffers[buf].getElemByte(y,x,band)&0xff);
226
//				 TO DO: TENER EN CUENTA NO DATA REAL DEL BUFER
227
				if(data==97)
228
					data=-128;
229
				result[band]=(byte) Math.max((byte)result[band],(byte)data);		
230
			}
231
			try {
232
				mosaicGrid.setBandToOperate(band);
233
				mosaicGrid.setCellValue(x,y,(byte)result[band]);
234
			} catch (OutOfGridException e) {
235
				// TODO Auto-generated catch block
228
	public void setValueMax(int x, int y, int band){
229
		byte result=-128;
230
		for(int buf=0;buf<buffers.length;buf++){
231
			byte data = (byte)(buffers[buf].getElemByte(y,x,band));
232
//				 TO DO: TENER EN CUENTA NODATA REAL DEL BUFER
233
			if(data==97)
234
				data=-128;
235
			result=(byte) Math.max((byte)result,(byte)data);		
236
		}
237
		try {
238
				mosaicGrid.setCellValue(x,y,(byte)result);
239
		} catch (OutOfGridException e) {
236 240
				e.printStackTrace();
237
			}
238 241
		}
239 242
	}
240 243
	
241
	
242 244
	/**
243 245
	 *  M?todo que establece para la coordenada x,y el valor m?ximo 
244 246
	 *  de todos los valores para ese p?xel en cualquiera de las imagenes.
......
272 274
	}
273 275
	
274 276
	
277
	/**
278
	 *  M?todo que establece para la coordenada x,y el valor medio  
279
	 *  de todos los valores para ese p?xel en cualquiera de las imagenes.
280
	 *  Si el valor en cualquiera de las imagenes es noData no es tenido en cuenta 
281
	 *  @param cordenada x 
282
	 *  @param coordenada y  
283
	 * */
284
	public void setValueMean(int x, int y, int band){
285
		int result=0;
286
		int buffTotales= buffers.length;
287
		for(int buf=0;buf<buffers.length;buf++){
288
			int data = (int)((byte)(buffers[buf].getElemByte(y,x,band)&0xff)+127);
289
//			TO DO: TENER EN CUENTA NODATA REAL DEL BUFER
290
			if(data==97+127){
291
				buffTotales--;
292
				data =0;
293
			}
294
			result+=data;		
295
		}
296
		if(buffTotales==0)
297
			buffTotales=1;
298
		result=(int)((result/buffTotales));
299
		try {
300
				mosaicGrid.setCellValue(x,y,(byte)(result-127));
301
		} catch (OutOfGridException e) {
302
				e.printStackTrace();
303
		}
304
	}
275 305
	
306
	
307
	
308
	
309
	
310
	
311
	
312
	
276 313
	/**
277 314
	 * M?todo que calcula el extend resultante para la operaci?n de mosaico
278 315
	 * 
......
304 341
			e.printStackTrace();
305 342
		}
306 343
		
307
		result = new GridExtent(minX,minY,maxX,maxY,25);
344
		result = new GridExtent(minX,minY,maxX,maxY,cellSize);
308 345
		return result;
309 346
	}
310 347
	

Also available in: Unified diff