Revision 11453
trunk/libraries/libRaster/src-test/org/gvsig/raster/buffer/TestBufferInterpolation.java | ||
---|---|---|
1 |
/* |
|
2 |
* Created on 9-ago-2006 |
|
3 |
* |
|
4 |
* To change the template for this generated file go to |
|
5 |
* Window>Preferences>Java>Code Generation>Code and Comments |
|
6 |
*/ |
|
7 |
/* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana |
|
8 |
* |
|
9 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
10 |
* |
|
11 |
* This program is free software; you can redistribute it and/or |
|
12 |
* modify it under the terms of the GNU General Public License |
|
13 |
* as published by the Free Software Foundation; either version 2 |
|
14 |
* of the License, or (at your option) any later version. |
|
15 |
* |
|
16 |
* This program is distributed in the hope that it will be useful, |
|
17 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
18 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
19 |
* GNU General Public License for more details. |
|
20 |
* |
|
21 |
* You should have received a copy of the GNU General Public License |
|
22 |
* along with this program; if not, write to the Free Software |
|
23 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
24 |
*/ |
|
25 |
package org.gvsig.raster.buffer; |
|
26 |
|
|
27 |
import java.io.File; |
|
28 |
import java.io.IOException; |
|
29 |
|
|
30 |
import junit.framework.TestCase; |
|
31 |
|
|
32 |
import org.gvsig.raster.RasterLibrary; |
|
33 |
import org.gvsig.raster.buffer.cache.WriterBufferServer; |
|
34 |
import org.gvsig.raster.dataset.GeoRasterWriter; |
|
35 |
import org.gvsig.raster.dataset.IBuffer; |
|
36 |
import org.gvsig.raster.dataset.IDataWriter; |
|
37 |
import org.gvsig.raster.dataset.NotSupportedExtensionException; |
|
38 |
import org.gvsig.raster.dataset.RasterDataset; |
|
39 |
import org.gvsig.raster.dataset.RasterDriverException; |
|
40 |
import org.gvsig.raster.dataset.WriterParams; |
|
41 |
import org.gvsig.raster.shared.Extent; |
|
42 |
|
|
43 |
/** |
|
44 |
* Test para probar las interpolaciones de un buffer de datos completo. El test crear? un |
|
45 |
* buffer a partir de una imagen de 870x870 y aplicar? una reducci?n usando los m?todos |
|
46 |
* de interpolaci?n implementados. Despu?s comparar? el resultado con imagenes ya generadas |
|
47 |
* y correctas que se encuentran en el directorio de test-images. |
|
48 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
49 |
* |
|
50 |
*/ |
|
51 |
public class TestBufferInterpolation extends TestCase { |
|
52 |
private String baseDir = "./test-images/"; |
|
53 |
private String path = baseDir + "03AUG23153350-M2AS-000000122423_01_P001-BROWSE.jpg"; |
|
54 |
private RasterDataset f = null; |
|
55 |
private BufferFactory ds = null; |
|
56 |
|
|
57 |
private String fileNeighbour1 = baseDir + "neighbour50x50.tif"; |
|
58 |
private String fileBilinear1 = baseDir + "bilinear50x50.tif"; |
|
59 |
|
|
60 |
private String fileNeighbour = "./f1.tif"; |
|
61 |
private String fileBilinear = "./f2.tif"; |
|
62 |
|
|
63 |
static { |
|
64 |
RasterLibrary.wakeUp(); |
|
65 |
} |
|
66 |
|
|
67 |
public void start() { |
|
68 |
this.setUp(); |
|
69 |
this.testStack(); |
|
70 |
} |
|
71 |
|
|
72 |
public void setUp() { |
|
73 |
System.err.println("TestBufferInterpolation running..."); |
|
74 |
int[] drawableBands = {0, 1, 2}; |
|
75 |
try { |
|
76 |
f = RasterDataset.open(null, path); |
|
77 |
} catch (NotSupportedExtensionException e) { |
|
78 |
e.printStackTrace(); |
|
79 |
return; |
|
80 |
} catch (RasterDriverException e) { |
|
81 |
e.printStackTrace(); |
|
82 |
return; |
|
83 |
} |
|
84 |
ds = new BufferFactory(f); |
|
85 |
ds.addDrawableBands(drawableBands); |
|
86 |
ds.setAreaOfInterest(0, 0, f.getWidth(), f.getHeight()); |
|
87 |
RasterBuffer buf = (RasterBuffer)ds.getRasterBuf(); |
|
88 |
|
|
89 |
IBuffer b1 = buf.getAdjustedWindow(50, 50, IQueryableRaster.INTERPOLATION_NearestNeighbour); |
|
90 |
IBuffer b2 = buf.getAdjustedWindow(50, 50, IQueryableRaster.INTERPOLATION_Bilinear); |
|
91 |
try { |
|
92 |
convertBufferToTif(fileNeighbour, f.getExtent(), b1); |
|
93 |
convertBufferToTif(fileBilinear, f.getExtent(), b2); |
|
94 |
} catch (IOException e) { |
|
95 |
e.printStackTrace(); |
|
96 |
} |
|
97 |
} |
|
98 |
|
|
99 |
public void testStack(){ |
|
100 |
compareResult(fileNeighbour, fileNeighbour1); |
|
101 |
//compareResult(fileBilinear, fileBilinear1); |
|
102 |
File file1 = new File(fileNeighbour); |
|
103 |
File file2 = new File(fileBilinear); |
|
104 |
if(file1.exists()) |
|
105 |
file1.delete(); |
|
106 |
if(file2.exists()) |
|
107 |
file2.delete(); |
|
108 |
} |
|
109 |
|
|
110 |
/** |
|
111 |
* Compara dos ficheros raster |
|
112 |
* @param f1 |
|
113 |
* @param f2 |
|
114 |
*/ |
|
115 |
private void compareResult(String f1, String f2) { |
|
116 |
int[] drawableBands = {0, 1, 2}; |
|
117 |
RasterDataset d1 = null; |
|
118 |
RasterDataset d2 = null; |
|
119 |
try { |
|
120 |
d1 = RasterDataset.open(null, f1); |
|
121 |
d2 = RasterDataset.open(null, f2); |
|
122 |
} catch (NotSupportedExtensionException e) { |
|
123 |
e.printStackTrace(); |
|
124 |
return; |
|
125 |
} catch (RasterDriverException e) { |
|
126 |
e.printStackTrace(); |
|
127 |
return; |
|
128 |
} |
|
129 |
BufferFactory ds = new BufferFactory(d1); |
|
130 |
ds.addDrawableBands(drawableBands); |
|
131 |
ds.setAreaOfInterest(0, 0, d1.getWidth(), d1.getHeight()); |
|
132 |
IBuffer b1 = ds.getRasterBuf(); |
|
133 |
|
|
134 |
ds = new BufferFactory(d2); |
|
135 |
ds.addDrawableBands(drawableBands); |
|
136 |
ds.setAreaOfInterest(0, 0, d1.getWidth(), d1.getHeight()); |
|
137 |
IBuffer b2 = ds.getRasterBuf(); |
|
138 |
|
|
139 |
for (int k = 0; k < b1.getBandCount(); k++) { |
|
140 |
for (int i = 0; i < b1.getHeight(); i++) { |
|
141 |
for (int j = 0; j < b1.getWidth(); j++) { |
|
142 |
switch(b1.getDataType()) { |
|
143 |
case IBuffer.TYPE_BYTE: |
|
144 |
assertEquals(b1.getElemByte(i, j, k), b2.getElemByte(i, j, k)); |
|
145 |
break; |
|
146 |
case IBuffer.TYPE_SHORT: |
|
147 |
assertEquals(b1.getElemShort(i, j, k), b2.getElemShort(i, j, k)); |
|
148 |
break; |
|
149 |
|
|
150 |
case IBuffer.TYPE_INT: |
|
151 |
assertEquals(b1.getElemInt(i, j, k), b2.getElemInt(i, j, k)); |
|
152 |
break; |
|
153 |
|
|
154 |
case IBuffer.TYPE_FLOAT: |
|
155 |
assertEquals((int)b1.getElemFloat(i, j, k), (int)b2.getElemFloat(i, j, k)); |
|
156 |
break; |
|
157 |
|
|
158 |
case IBuffer.TYPE_DOUBLE: |
|
159 |
assertEquals((int)b1.getElemDouble(i, j, k), (int)b2.getElemDouble(i, j, k)); |
|
160 |
break; |
|
161 |
} |
|
162 |
} |
|
163 |
} |
|
164 |
} |
|
165 |
} |
|
166 |
|
|
167 |
/** |
|
168 |
* Funci?n para pruebas. |
|
169 |
* Convierte los ficheros generados por la funci?n cachear en ficheros tif para comprobar que est?n |
|
170 |
* bien generados. |
|
171 |
* @param grf |
|
172 |
* @param pageBuffer |
|
173 |
* @param pageLines |
|
174 |
* @throws IOException |
|
175 |
*/ |
|
176 |
private void convertBufferToTif(String fileName, Extent ext, IBuffer buffer)throws IOException { |
|
177 |
IDataWriter dataWriter1 = new WriterBufferServer(buffer); |
|
178 |
GeoRasterWriter grw = null; |
|
179 |
try { |
|
180 |
WriterParams params = GeoRasterWriter.getWriter(fileName).getParams(); |
|
181 |
params.changeParamValue("blocksize", "512"); |
|
182 |
params.changeParamValue("tfw", "false"); |
|
183 |
params.changeParamValue("interleave", "PIXEL"); |
|
184 |
grw = GeoRasterWriter.getWriter(dataWriter1, |
|
185 |
fileName, |
|
186 |
buffer.getBandCount(), |
|
187 |
ext, |
|
188 |
buffer.getWidth(), |
|
189 |
buffer.getHeight(), |
|
190 |
buffer.getDataType(), |
|
191 |
params); |
|
192 |
|
|
193 |
} catch (NotSupportedExtensionException e) { |
|
194 |
e.printStackTrace(); |
|
195 |
} catch (RasterDriverException e) { |
|
196 |
e.printStackTrace(); |
|
197 |
} |
|
198 |
grw.dataWrite(); |
|
199 |
grw.writeClose(); |
|
200 |
} |
|
201 |
|
|
202 |
} |
|
0 | 203 |
trunk/libraries/libRaster/src/org/gvsig/raster/buffer/BufferFactory.java | ||
---|---|---|
397 | 397 |
|
398 | 398 |
rasterBuf = mDataset.getWindowRaster(x, y, w, h, bufWidth, bufHeight); |
399 | 399 |
} |
400 |
|
|
401 |
/** |
|
402 |
* Ajusta el ?rea del grid a un ancho y un alto dado en pixeles. Este ajuste se har? |
|
403 |
* en relaci?n a un m?todo de interpolaci?n definido en el par?metro. |
|
404 |
* @param w Ancho de la nueva imagen. |
|
405 |
* @param h Alto de la nueva imagen. |
|
406 |
* @param interpolation M?todo de interpolaci?n que se usar? en el ajuste. |
|
407 |
* @param bands Bandas que se desea en el nuevo RasterBuf ajustado. Si este par?metro es null |
|
408 |
* se usar?n todas las bandas de la imagen. |
|
409 |
*/ |
|
410 |
public void setAdjustedWindow(int w, int h, int interpolationMethod, int[] bands) { |
|
411 |
if(w == width && h == height) |
|
412 |
return; |
|
413 |
switch(interpolationMethod) { |
|
414 |
case IQueryableRaster.INTERPOLATION_NearestNeighbour: |
|
415 |
rasterBuf = ((RasterBuffer)rasterBuf).adjustRasterNearestNeighbourInterpolation(w, h, bands); |
|
416 |
break; |
|
417 |
case IQueryableRaster.INTERPOLATION_Bilinear: |
|
418 |
System.out.println("Method not implemented yet"); |
|
419 |
break; |
|
420 |
case IQueryableRaster.INTERPOLATION_InverseDistance: |
|
421 |
System.out.println("Method not implemented yet"); |
|
422 |
break; |
|
423 |
case IQueryableRaster.INTERPOLATION_BicubicSpline: |
|
424 |
System.out.println("Method not implemented yet"); |
|
425 |
break; |
|
426 |
case IQueryableRaster.INTERPOLATION_BSpline: |
|
427 |
System.out.println("Method not implemented yet"); |
|
428 |
break; |
|
429 |
} |
|
430 |
//width = rasterBuf.getWidth(); |
|
431 |
//height = rasterBuf.getHeight(); |
|
432 |
} |
|
433 | 400 |
|
434 | 401 |
/** |
435 | 402 |
* Obtiene el tipo de datos del grid. |
trunk/libraries/libRaster/src/org/gvsig/raster/buffer/RasterMemoryBuffer.java | ||
---|---|---|
1093 | 1093 |
return null; |
1094 | 1094 |
} |
1095 | 1095 |
|
1096 |
/* |
|
1097 |
* (non-Javadoc) |
|
1098 |
* @see org.gvsig.fmap.buffer.raster.RasterBuffer#adjustRasterNearestNeighbourInterpolation(int, int, int[]) |
|
1099 |
*/ |
|
1100 |
public RasterBuffer adjustRasterNearestNeighbourInterpolation(int w, int h, int[] bands){ |
|
1101 |
double stepX = (double)w / (double)width; |
|
1102 |
double stepY = (double)h / (double)height; |
|
1103 |
RasterBuffer rasterBuf = new RasterMemoryBuffer(getDataType(), w, h, getBandCount(), true); |
|
1104 |
|
|
1105 |
//Si bands == null las bandas a copiar son todas las de la imagen |
|
1106 |
if(bands == null){ |
|
1107 |
bands = new int[rasterBuf.getBandCount()]; |
|
1108 |
for(int iBand = 0; iBand < rasterBuf.getBandCount(); iBand ++) |
|
1109 |
bands[iBand] = iBand; |
|
1110 |
} |
|
1111 |
|
|
1112 |
switch (dataType) { |
|
1113 |
case RasterBuffer.TYPE_IMAGE: |
|
1114 |
|
|
1115 |
case RasterBuffer.TYPE_BYTE: |
|
1116 |
for(int iBand = 0; iBand < bands.length; iBand ++){ |
|
1117 |
if(w <= width){ //submuestreo |
|
1118 |
for(int iRow = 0; iRow < height; iRow ++) |
|
1119 |
for(int iCol = 0; iCol < width; iCol ++) |
|
1120 |
rasterBuf.setElem((int)(iRow * stepY), (int)(iCol * stepX), bands[iBand], getElemByte(iRow, iCol, iBand)); |
|
1121 |
}else{ //supermuestreo |
|
1122 |
for(int iRow = 0; iRow < h; iRow ++) |
|
1123 |
for(int iCol = 0; iCol < w; iCol ++) |
|
1124 |
rasterBuf.setElem(iRow, iCol, bands[iBand], getElemByte((int)(iRow / stepY), (int)(iCol / stepX), iBand)); |
|
1125 |
} |
|
1126 |
} |
|
1127 |
break; |
|
1128 |
case RasterBuffer.TYPE_DOUBLE: |
|
1129 |
for(int iBand = 0; iBand < bands.length; iBand ++){ |
|
1130 |
if(w <= width){ //submuestreo |
|
1131 |
for(int iRow = 0; iRow < height; iRow ++) |
|
1132 |
for(int iCol = 0; iCol < width; iCol ++) |
|
1133 |
rasterBuf.setElem((int)(iRow * stepY), (int)(iCol * stepX), bands[iBand], getElemDouble(iRow, iCol, iBand)); |
|
1134 |
}else{ //supermuestreo |
|
1135 |
for(int iRow = 0; iRow < h; iRow ++) |
|
1136 |
for(int iCol = 0; iCol < w; iCol ++) |
|
1137 |
rasterBuf.setElem(iRow, iCol, bands[iBand], getElemDouble((int)(iRow / stepY), (int)(iCol / stepX), iBand)); |
|
1138 |
} |
|
1139 |
} |
|
1140 |
break; |
|
1141 |
case RasterBuffer.TYPE_FLOAT: |
|
1142 |
for(int iBand = 0; iBand < bands.length; iBand ++){ |
|
1143 |
if(w <= width){ //submuestreo |
|
1144 |
for(int iRow = 0; iRow < height; iRow ++) |
|
1145 |
for(int iCol = 0; iCol < width; iCol ++) |
|
1146 |
rasterBuf.setElem((int)(iRow * stepY), (int)(iCol * stepX), bands[iBand], getElemFloat(iRow, iCol, iBand)); |
|
1147 |
}else{ //supermuestreo |
|
1148 |
for(int iRow = 0; iRow < h; iRow ++) |
|
1149 |
for(int iCol = 0; iCol < w; iCol ++) |
|
1150 |
rasterBuf.setElem(iRow, iCol, bands[iBand], getElemFloat((int)(iRow / stepY), (int)(iCol / stepX), iBand)); |
|
1151 |
} |
|
1152 |
} |
|
1153 |
break; |
|
1154 |
case RasterBuffer.TYPE_INT: |
|
1155 |
for(int iBand = 0; iBand < bands.length; iBand ++){ |
|
1156 |
if(w <= width){ //submuestreo |
|
1157 |
for(int iRow = 0; iRow < height; iRow ++) |
|
1158 |
for(int iCol = 0; iCol < width; iCol ++) |
|
1159 |
rasterBuf.setElem((int)(iRow * stepY), (int)(iCol * stepX), bands[iBand], getElemInt(iRow, iCol, iBand)); |
|
1160 |
}else{ //supermuestreo |
|
1161 |
for(int iRow = 0; iRow < h; iRow ++) |
|
1162 |
for(int iCol = 0; iCol < w; iCol ++) |
|
1163 |
rasterBuf.setElem(iRow, iCol, bands[iBand], getElemInt((int)(iRow / stepY), (int)(iCol / stepX), iBand)); |
|
1164 |
} |
|
1165 |
} |
|
1166 |
break; |
|
1167 |
case RasterBuffer.TYPE_USHORT: |
|
1168 |
case RasterBuffer.TYPE_SHORT: |
|
1169 |
for(int iBand = 0; iBand < bands.length; iBand ++){ |
|
1170 |
if(w <= width){ //submuestreo |
|
1171 |
for(int iRow = 0; iRow < height; iRow ++) |
|
1172 |
for(int iCol = 0; iCol < width; iCol ++) |
|
1173 |
rasterBuf.setElem((int)(iRow * stepY), (int)(iCol * stepX), bands[iBand], getElemShort(iRow, iCol, iBand)); |
|
1174 |
}else{ //supermuestreo |
|
1175 |
for(int iRow = 0; iRow < h; iRow ++) |
|
1176 |
for(int iCol = 0; iCol < w; iCol ++) |
|
1177 |
rasterBuf.setElem(iRow, iCol, bands[iBand], getElemShort((int)(iRow / stepY), (int)(iCol / stepX), iBand)); |
|
1178 |
} |
|
1179 |
} |
|
1180 |
break; |
|
1181 |
} |
|
1182 |
return rasterBuf; |
|
1183 |
} |
|
1184 |
|
|
1185 |
/* |
|
1186 |
* (non-Javadoc) |
|
1187 |
* @see org.gvsig.fmap.buffer.raster.RasterBuffer#adjustRasterBilinearInterpolation(int, int, int[]) |
|
1188 |
*/ |
|
1189 |
public RasterBuffer adjustRasterBilinearInterpolation(int w, int h, int[] bands) { |
|
1190 |
return null; |
|
1191 |
} |
|
1192 |
|
|
1193 |
/* |
|
1194 |
* (non-Javadoc) |
|
1195 |
* @see org.gvsig.fmap.buffer.raster.RasterBuffer#adjustRasterInverseDistanceInterpolation(int, int, int[]) |
|
1196 |
*/ |
|
1197 |
public RasterBuffer adjustRasterInverseDistanceInterpolation(int w, int h, int[] bands) { |
|
1198 |
return null; |
|
1199 |
} |
|
1200 |
|
|
1201 |
/* |
|
1202 |
* (non-Javadoc) |
|
1203 |
* @see org.gvsig.fmap.buffer.raster.RasterBuffer#adjustRasterBicubicSplineInterpolation(int, int, int[]) |
|
1204 |
*/ |
|
1205 |
public RasterBuffer adjustRasterBicubicSplineInterpolation(int w, int h, int[] bands) { |
|
1206 |
return null; |
|
1207 |
} |
|
1208 |
|
|
1209 |
/* |
|
1210 |
* (non-Javadoc) |
|
1211 |
* @see org.gvsig.fmap.buffer.raster.RasterBuffer#adjustRasterBSplineInterpolation(int, int, int[]) |
|
1212 |
*/ |
|
1213 |
public RasterBuffer adjustRasterBSplineInterpolation(int w, int h, int[] bands) { |
|
1214 |
return null; |
|
1215 |
} |
|
1216 |
|
|
1217 | 1096 |
private ByteBand byteNotValid; |
1218 | 1097 |
private ShortBand shortNotValid; |
1219 | 1098 |
private IntBand intNotValid; |
... | ... | |
1224 | 1103 |
* (non-Javadoc) |
1225 | 1104 |
* @see org.gvsig.fmap.driver.IBuffer#assignBandToNotValid(int) |
1226 | 1105 |
*/ |
1227 |
public void assignBandToNotValid(int iBand){ |
|
1106 |
public void assignBandToNotValid(int iBand) {
|
|
1228 | 1107 |
switch(getDataType()){ |
1229 |
case IBuffer.TYPE_BYTE: if(byteNotValid == null){ |
|
1108 |
case IBuffer.TYPE_BYTE: if(byteNotValid == null) {
|
|
1230 | 1109 |
byteNotValid = new ByteBand(getHeight(), getWidth(), true); |
1231 | 1110 |
for(int i = 0 ; i < getWidth(); i ++) |
1232 | 1111 |
for(int j = 0 ; j < getHeight(); j ++) |
... | ... | |
1234 | 1113 |
} |
1235 | 1114 |
byteBuf[iBand] = byteNotValid; |
1236 | 1115 |
break; |
1237 |
case IBuffer.TYPE_SHORT: if(shortNotValid == null){ |
|
1116 |
case IBuffer.TYPE_SHORT: if(shortNotValid == null) {
|
|
1238 | 1117 |
shortNotValid = new ShortBand(getHeight(), getWidth(), true); |
1239 | 1118 |
for(int i = 0 ; i < getWidth(); i ++) |
1240 | 1119 |
for(int j = 0 ; j < getHeight(); j ++) |
... | ... | |
1242 | 1121 |
} |
1243 | 1122 |
shortBuf[iBand] = shortNotValid; |
1244 | 1123 |
break; |
1245 |
case IBuffer.TYPE_INT: if(intNotValid == null){ |
|
1124 |
case IBuffer.TYPE_INT: if(intNotValid == null) {
|
|
1246 | 1125 |
intNotValid = new IntBand(getHeight(), getWidth(), true); |
1247 | 1126 |
for(int i = 0 ; i < getWidth(); i ++) |
1248 | 1127 |
for(int j = 0 ; j < getHeight(); j ++) |
... | ... | |
1250 | 1129 |
} |
1251 | 1130 |
intBuf[iBand] = intNotValid; |
1252 | 1131 |
break; |
1253 |
case IBuffer.TYPE_FLOAT: if(floatNotValid == null){ |
|
1132 |
case IBuffer.TYPE_FLOAT: if(floatNotValid == null) {
|
|
1254 | 1133 |
floatNotValid = new FloatBand(getHeight(), getWidth(), true); |
1255 | 1134 |
for(int i = 0 ; i < getWidth(); i ++) |
1256 | 1135 |
for(int j = 0 ; j < getHeight(); j ++) |
... | ... | |
1258 | 1137 |
} |
1259 | 1138 |
floatBuf[iBand] = floatNotValid; |
1260 | 1139 |
break; |
1261 |
case IBuffer.TYPE_DOUBLE: if(doubleNotValid == null){ |
|
1140 |
case IBuffer.TYPE_DOUBLE: if(doubleNotValid == null) {
|
|
1262 | 1141 |
doubleNotValid = new DoubleBand(getHeight(), getWidth(), true); |
1263 | 1142 |
for(int i = 0 ; i < getWidth(); i ++) |
1264 | 1143 |
for(int j = 0 ; j < getHeight(); j ++) |
trunk/libraries/libRaster/src/org/gvsig/raster/buffer/cache/RasterReadOnlyHugeBuffer.java | ||
---|---|---|
415 | 415 |
} |
416 | 416 |
|
417 | 417 |
//********************************************************* |
418 |
|
|
419 |
public RasterBuffer adjustRasterNearestNeighbourInterpolation(int w, int h, int[] bands) { |
|
420 |
return null; |
|
421 |
} |
|
422 |
|
|
423 |
public RasterBuffer adjustRasterBilinearInterpolation(int w, int h, int[] bands) { |
|
424 |
return null; |
|
425 |
} |
|
426 |
|
|
427 |
public RasterBuffer adjustRasterInverseDistanceInterpolation(int w, int h, int[] bands) { |
|
428 |
return null; |
|
429 |
} |
|
430 |
|
|
431 |
public RasterBuffer adjustRasterBicubicSplineInterpolation(int w, int h, int[] bands) { |
|
432 |
return null; |
|
433 |
} |
|
434 |
|
|
435 |
public RasterBuffer adjustRasterBSplineInterpolation(int w, int h, int[] bands) { |
|
436 |
return null; |
|
437 |
} |
|
438 |
|
|
418 |
|
|
439 | 419 |
/* |
440 | 420 |
* (non-Javadoc) |
441 | 421 |
* @see org.gvsig.fmap.driver.IBuffer#cloneBuffer() |
trunk/libraries/libRaster/src/org/gvsig/raster/buffer/cache/RasterCache.java | ||
---|---|---|
484 | 484 |
|
485 | 485 |
//********************************************************* |
486 | 486 |
|
487 |
public RasterBuffer adjustRasterNearestNeighbourInterpolation(int w, int h, int[] bands) { |
|
488 |
return null; |
|
489 |
} |
|
490 |
|
|
491 |
public RasterBuffer adjustRasterBilinearInterpolation(int w, int h, int[] bands) { |
|
492 |
return null; |
|
493 |
} |
|
494 |
|
|
495 |
public RasterBuffer adjustRasterInverseDistanceInterpolation(int w, int h, int[] bands) { |
|
496 |
return null; |
|
497 |
} |
|
498 |
|
|
499 |
public RasterBuffer adjustRasterBicubicSplineInterpolation(int w, int h, int[] bands) { |
|
500 |
return null; |
|
501 |
} |
|
502 |
|
|
503 |
public RasterBuffer adjustRasterBSplineInterpolation(int w, int h, int[] bands) { |
|
504 |
return null; |
|
505 |
} |
|
506 |
|
|
507 |
//********************************************************* |
|
508 |
|
|
509 | 487 |
public void assign(int band, byte value) { |
510 | 488 |
for(int line = 0; line < height; line ++){ |
511 | 489 |
boolean beginLine = true; //Para acelerar solo comprobar? si la p?gina est? en cach? cada vez que empieza una l?nea |
trunk/libraries/libRaster/src/org/gvsig/raster/buffer/RasterBuffer.java | ||
---|---|---|
276 | 276 |
* @param w Nuevo ancho |
277 | 277 |
* @param h Nuevo alto |
278 | 278 |
*/ |
279 |
public abstract RasterBuffer adjustRasterNearestNeighbourInterpolation(int w, int h, int[] bands); |
|
279 |
private RasterBuffer adjustRasterNearestNeighbourInterpolation(int w, int h) { |
|
280 |
double stepX = (double)w / (double)width; |
|
281 |
double stepY = (double)h / (double)height; |
|
282 |
RasterBuffer rasterBuf = new RasterMemoryBuffer(getDataType(), w, h, getBandCount(), true); |
|
283 |
|
|
284 |
int[] bands = new int[rasterBuf.getBandCount()]; |
|
285 |
for(int iBand = 0; iBand < rasterBuf.getBandCount(); iBand ++) |
|
286 |
bands[iBand] = iBand; |
|
287 |
|
|
288 |
|
|
289 |
switch (dataType) { |
|
290 |
case RasterBuffer.TYPE_BYTE: |
|
291 |
for(int iBand = 0; iBand < bands.length; iBand ++) { |
|
292 |
if(w <= width) { //submuestreo |
|
293 |
for(int iRow = 0; iRow < height; iRow ++) |
|
294 |
for(int iCol = 0; iCol < width; iCol ++) |
|
295 |
rasterBuf.setElem((int)(iRow * stepY), (int)(iCol * stepX), bands[iBand], getElemByte(iRow, iCol, iBand)); |
|
296 |
}else{ //supermuestreo |
|
297 |
for(int iRow = 0; iRow < h; iRow ++) |
|
298 |
for(int iCol = 0; iCol < w; iCol ++) |
|
299 |
rasterBuf.setElem(iRow, iCol, bands[iBand], getElemByte((int)(iRow / stepY), (int)(iCol / stepX), iBand)); |
|
300 |
} |
|
301 |
} |
|
302 |
break; |
|
303 |
case RasterBuffer.TYPE_DOUBLE: |
|
304 |
for(int iBand = 0; iBand < bands.length; iBand ++) { |
|
305 |
if(w <= width) { //submuestreo |
|
306 |
for(int iRow = 0; iRow < height; iRow ++) |
|
307 |
for(int iCol = 0; iCol < width; iCol ++) |
|
308 |
rasterBuf.setElem((int)(iRow * stepY), (int)(iCol * stepX), bands[iBand], getElemDouble(iRow, iCol, iBand)); |
|
309 |
}else{ //supermuestreo |
|
310 |
for(int iRow = 0; iRow < h; iRow ++) |
|
311 |
for(int iCol = 0; iCol < w; iCol ++) |
|
312 |
rasterBuf.setElem(iRow, iCol, bands[iBand], getElemDouble((int)(iRow / stepY), (int)(iCol / stepX), iBand)); |
|
313 |
} |
|
314 |
} |
|
315 |
break; |
|
316 |
case RasterBuffer.TYPE_FLOAT: |
|
317 |
for(int iBand = 0; iBand < bands.length; iBand ++) { |
|
318 |
if(w <= width) { //submuestreo |
|
319 |
for(int iRow = 0; iRow < height; iRow ++) |
|
320 |
for(int iCol = 0; iCol < width; iCol ++) |
|
321 |
rasterBuf.setElem((int)(iRow * stepY), (int)(iCol * stepX), bands[iBand], getElemFloat(iRow, iCol, iBand)); |
|
322 |
}else{ //supermuestreo |
|
323 |
for(int iRow = 0; iRow < h; iRow ++) |
|
324 |
for(int iCol = 0; iCol < w; iCol ++) |
|
325 |
rasterBuf.setElem(iRow, iCol, bands[iBand], getElemFloat((int)(iRow / stepY), (int)(iCol / stepX), iBand)); |
|
326 |
} |
|
327 |
} |
|
328 |
break; |
|
329 |
case RasterBuffer.TYPE_INT: |
|
330 |
for(int iBand = 0; iBand < bands.length; iBand ++) { |
|
331 |
if(w <= width) { //submuestreo |
|
332 |
for(int iRow = 0; iRow < height; iRow ++) |
|
333 |
for(int iCol = 0; iCol < width; iCol ++) |
|
334 |
rasterBuf.setElem((int)(iRow * stepY), (int)(iCol * stepX), bands[iBand], getElemInt(iRow, iCol, iBand)); |
|
335 |
}else{ //supermuestreo |
|
336 |
for(int iRow = 0; iRow < h; iRow ++) |
|
337 |
for(int iCol = 0; iCol < w; iCol ++) |
|
338 |
rasterBuf.setElem(iRow, iCol, bands[iBand], getElemInt((int)(iRow / stepY), (int)(iCol / stepX), iBand)); |
|
339 |
} |
|
340 |
} |
|
341 |
break; |
|
342 |
case RasterBuffer.TYPE_USHORT: |
|
343 |
case RasterBuffer.TYPE_SHORT: |
|
344 |
for(int iBand = 0; iBand < bands.length; iBand ++) { |
|
345 |
if(w <= width) { //submuestreo |
|
346 |
for(int iRow = 0; iRow < height; iRow ++) |
|
347 |
for(int iCol = 0; iCol < width; iCol ++) |
|
348 |
rasterBuf.setElem((int)(iRow * stepY), (int)(iCol * stepX), bands[iBand], getElemShort(iRow, iCol, iBand)); |
|
349 |
}else{ //supermuestreo |
|
350 |
for(int iRow = 0; iRow < h; iRow ++) |
|
351 |
for(int iCol = 0; iCol < w; iCol ++) |
|
352 |
rasterBuf.setElem(iRow, iCol, bands[iBand], getElemShort((int)(iRow / stepY), (int)(iCol / stepX), iBand)); |
|
353 |
} |
|
354 |
} |
|
355 |
break; |
|
356 |
} |
|
357 |
return rasterBuf; |
|
358 |
} |
|
280 | 359 |
|
281 | 360 |
/** |
282 | 361 |
* Ajusta el raster al ancho y alto solicitado ajustando con una interpolaci?n bilineal. Promedia |
... | ... | |
284 | 363 |
* @param w Nuevo ancho |
285 | 364 |
* @param h Nuevo alto |
286 | 365 |
*/ |
287 |
public abstract RasterBuffer adjustRasterBilinearInterpolation(int w, int h, int[] bands); |
|
366 |
private RasterBuffer adjustRasterBilinearInterpolation(int w, int h) { |
|
367 |
double pxSize = (double)width / (double)w; |
|
368 |
RasterBuffer rasterBuf = new RasterMemoryBuffer(getDataType(), w, h, getBandCount(), true); |
|
369 |
|
|
370 |
double posX = pxSize / 2D; |
|
371 |
double posY = posX; |
|
372 |
double dx = 0D, dy = 0D; |
|
373 |
|
|
374 |
for(int iBand = 0; iBand < getBandCount(); iBand ++) { |
|
375 |
posY = pxSize / 2D; |
|
376 |
switch (dataType) { |
|
377 |
case RasterBuffer.TYPE_BYTE: |
|
378 |
for(int iRow = 0; iRow < h; iRow ++) { |
|
379 |
dy = posY - ((int)posY); |
|
380 |
posX = pxSize / 2D; |
|
381 |
for(int iCol = 0; iCol < w; iCol ++) { |
|
382 |
dx = posX - ((int)posX); |
|
383 |
double[] kernel = getKernelByte(((int)posX), ((int)posY), iBand); |
|
384 |
double[] nz = getBilinearNZ(dx, dy, kernel); |
|
385 |
double b = 0; |
|
386 |
if(nz[0] > 0.0) |
|
387 |
b = (nz[1] / nz[0]); |
|
388 |
rasterBuf.setElem(iRow, iCol, iBand, (byte)((byte)b & 0xff)); |
|
389 |
posX += pxSize; |
|
390 |
} |
|
391 |
posY += pxSize; |
|
392 |
} |
|
393 |
break; |
|
394 |
case RasterBuffer.TYPE_SHORT: |
|
395 |
for(int iRow = 0; iRow < h; iRow ++) { |
|
396 |
dy = posY - ((int)posY); |
|
397 |
posX = pxSize / 2D; |
|
398 |
for(int iCol = 0; iCol < w; iCol ++) { |
|
399 |
dx = posX - ((int)posX); |
|
400 |
double[] kernel = getKernelShort(((int)posX), ((int)posY), iBand); |
|
401 |
double[] nz = getBilinearNZ(dx, dy, kernel); |
|
402 |
double b = 0; |
|
403 |
if(nz[0] > 0.0) |
|
404 |
b = (nz[1] / nz[0]); |
|
405 |
rasterBuf.setElem(iRow, iCol, iBand, (short)((short)b & 0xffff)); |
|
406 |
posX += pxSize; |
|
407 |
} |
|
408 |
posY += pxSize; |
|
409 |
} |
|
410 |
break; |
|
411 |
case RasterBuffer.TYPE_INT: |
|
412 |
for(int iRow = 0; iRow < h; iRow ++) { |
|
413 |
dy = posY - ((int)posY); |
|
414 |
posX = pxSize / 2D; |
|
415 |
for(int iCol = 0; iCol < w; iCol ++) { |
|
416 |
dx = posX - ((int)posX); |
|
417 |
double[] kernel = getKernelInt(((int)posX), ((int)posY), iBand); |
|
418 |
double[] nz = getBilinearNZ(dx, dy, kernel); |
|
419 |
double b = 0; |
|
420 |
if(nz[0] > 0.0) |
|
421 |
b = (nz[1] / nz[0]); |
|
422 |
rasterBuf.setElem(iRow, iCol, iBand, (int)((int)b & 0xff)); |
|
423 |
posX += pxSize; |
|
424 |
} |
|
425 |
posY += pxSize; |
|
426 |
} |
|
427 |
break; |
|
428 |
case RasterBuffer.TYPE_FLOAT: |
|
429 |
for(int iRow = 0; iRow < h; iRow ++) { |
|
430 |
dy = posY - ((int)posY); |
|
431 |
posX = pxSize / 2D; |
|
432 |
for(int iCol = 0; iCol < w; iCol ++) { |
|
433 |
dx = posX - ((int)posX); |
|
434 |
double[] kernel = getKernelFloat(((int)posX), ((int)posY), iBand); |
|
435 |
double[] nz = getBilinearNZ(dx, dy, kernel); |
|
436 |
double b = 0; |
|
437 |
if(nz[0] > 0.0) |
|
438 |
b = (nz[1] / nz[0]); |
|
439 |
rasterBuf.setElem(iRow, iCol, iBand, (float)b); |
|
440 |
posX += pxSize; |
|
441 |
} |
|
442 |
posY += pxSize; |
|
443 |
} |
|
444 |
break; |
|
445 |
case RasterBuffer.TYPE_DOUBLE: |
|
446 |
for(int iRow = 0; iRow < h; iRow ++) { |
|
447 |
dy = posY - ((int)posY); |
|
448 |
posX = pxSize / 2D; |
|
449 |
for(int iCol = 0; iCol < w; iCol ++) { |
|
450 |
dx = posX - ((int)posX); |
|
451 |
double[] kernel = getKernelDouble(((int)posX), ((int)posY), iBand); |
|
452 |
double[] nz = getBilinearNZ(dx, dy, kernel); |
|
453 |
double b = 0; |
|
454 |
if(nz[0] > 0.0) |
|
455 |
b = (nz[1] / nz[0]); |
|
456 |
rasterBuf.setElem(iRow, iCol, iBand, (double)b); |
|
457 |
posX += pxSize; |
|
458 |
} |
|
459 |
posY += pxSize; |
|
460 |
} |
|
461 |
break; |
|
462 |
} |
|
463 |
|
|
464 |
} |
|
465 |
|
|
466 |
return rasterBuf; |
|
467 |
} |
|
288 | 468 |
|
289 | 469 |
/** |
470 |
* Calcula los valores N y Z para el m?todo bilinear |
|
471 |
* @param dx |
|
472 |
* @param dy |
|
473 |
* @param kernel |
|
474 |
* @return |
|
475 |
*/ |
|
476 |
private double[] getBilinearNZ(double dx, double dy, double[] kernel) { |
|
477 |
double z = 0.0, n = 0.0, d; |
|
478 |
d = (1.0 - dx) * (1.0 - dy); |
|
479 |
z += d * kernel[0]; |
|
480 |
n += d; |
|
481 |
|
|
482 |
d = dx * (1.0 - dy); |
|
483 |
z += d * kernel[1]; |
|
484 |
n += d; |
|
485 |
|
|
486 |
d = (1.0 - dx) * dy; |
|
487 |
z += d * kernel[2]; |
|
488 |
n += d; |
|
489 |
|
|
490 |
d = dx * dy; |
|
491 |
z += d * kernel[3]; |
|
492 |
n += d; |
|
493 |
return new double[]{n, z}; |
|
494 |
} |
|
495 |
|
|
496 |
/** |
|
497 |
* Obtiene un kernel de cuatro elemento que corresponden a los pixeles (x, y), (x + 1, y), |
|
498 |
* (x, y + 1), (x + 1, y + 1). Si los pixeles x + 1 o y + 1 se salen del raster de origen |
|
499 |
* se tomar? x e y. |
|
500 |
* @param x Coordenada X del pixel inicial |
|
501 |
* @param y Coordenada Y del pixel inicial |
|
502 |
* @param band N?mero de banda. |
|
503 |
* @return Kernel solicitado en forma de array. |
|
504 |
*/ |
|
505 |
private double[] getKernelByte(int x, int y, int band) { |
|
506 |
double[] d = new double[4]; |
|
507 |
d[0] = (getElemByte(y, x, band) & 0xff); |
|
508 |
int nextX = ((x + 1) >= getWidth()) ? x : (x + 1); |
|
509 |
int nextY = ((y + 1) >= getHeight()) ? y : (y + 1); |
|
510 |
d[1] = (getElemByte(y, nextX, band) & 0xff); |
|
511 |
d[2] = (getElemByte(nextY, x, band) & 0xff); |
|
512 |
d[3] = (getElemByte(nextY, nextX, band) & 0xff); |
|
513 |
return d; |
|
514 |
} |
|
515 |
|
|
516 |
/** |
|
517 |
* Obtiene un kernel de cuatro elemento que corresponden a los pixeles (x, y), (x + 1, y), |
|
518 |
* (x, y + 1), (x + 1, y + 1). Si los pixeles x + 1 o y + 1 se salen del raster de origen |
|
519 |
* se tomar? x e y. |
|
520 |
* @param x Coordenada X del pixel inicial |
|
521 |
* @param y Coordenada Y del pixel inicial |
|
522 |
* @param band N?mero de banda. |
|
523 |
* @return Kernel solicitado en forma de array. |
|
524 |
*/ |
|
525 |
private double[] getKernelShort(int x, int y, int band) { |
|
526 |
double[] d = new double[4]; |
|
527 |
d[0] = (getElemShort(y, x, band) & 0xffff); |
|
528 |
int nextX = ((x + 1) >= getWidth()) ? x : (x + 1); |
|
529 |
int nextY = ((y + 1) >= getHeight()) ? y : (y + 1); |
|
530 |
d[1] = (getElemShort(y, nextX, band) & 0xffff); |
|
531 |
d[2] = (getElemShort(nextY, x, band) & 0xffff); |
|
532 |
d[3] = (getElemShort(nextY, nextX, band) & 0xffff); |
|
533 |
return d; |
|
534 |
} |
|
535 |
|
|
536 |
/** |
|
537 |
* Obtiene un kernel de cuatro elemento que corresponden a los pixeles (x, y), (x + 1, y), |
|
538 |
* (x, y + 1), (x + 1, y + 1). Si los pixeles x + 1 o y + 1 se salen del raster de origen |
|
539 |
* se tomar? x e y. |
|
540 |
* @param x Coordenada X del pixel inicial |
|
541 |
* @param y Coordenada Y del pixel inicial |
|
542 |
* @param band N?mero de banda. |
|
543 |
* @return Kernel solicitado en forma de array. |
|
544 |
*/ |
|
545 |
private double[] getKernelInt(int x, int y, int band) { |
|
546 |
double[] d = new double[4]; |
|
547 |
d[0] = (getElemInt(y, x, band) & 0xffffffff); |
|
548 |
int nextX = ((x + 1) >= getWidth()) ? x : (x + 1); |
|
549 |
int nextY = ((y + 1) >= getHeight()) ? y : (y + 1); |
|
550 |
d[1] = (getElemInt(y, nextX, band) & 0xffffffff); |
|
551 |
d[2] = (getElemInt(nextY, x, band) & 0xffffffff); |
|
552 |
d[3] = (getElemInt(nextY, nextX, band) & 0xffffffff); |
|
553 |
return d; |
|
554 |
} |
|
555 |
|
|
556 |
/** |
|
557 |
* Obtiene un kernel de cuatro elemento que corresponden a los pixeles (x, y), (x + 1, y), |
|
558 |
* (x, y + 1), (x + 1, y + 1). Si los pixeles x + 1 o y + 1 se salen del raster de origen |
|
559 |
* se tomar? x e y. |
|
560 |
* @param x Coordenada X del pixel inicial |
|
561 |
* @param y Coordenada Y del pixel inicial |
|
562 |
* @param band N?mero de banda. |
|
563 |
* @return Kernel solicitado en forma de array. |
|
564 |
*/ |
|
565 |
private double[] getKernelFloat(int x, int y, int band) { |
|
566 |
double[] d = new double[4]; |
|
567 |
d[0] = getElemFloat(y, x, band); |
|
568 |
int nextX = ((x + 1) >= getWidth()) ? x : (x + 1); |
|
569 |
int nextY = ((y + 1) >= getHeight()) ? y : (y + 1); |
|
570 |
d[1] = getElemFloat(y, nextX, band); |
|
571 |
d[2] = getElemFloat(nextY, x, band); |
|
572 |
d[3] = getElemFloat(nextY, nextX, band); |
|
573 |
return d; |
|
574 |
} |
|
575 |
|
|
576 |
/** |
|
577 |
* Obtiene un kernel de cuatro elemento que corresponden a los pixeles (x, y), (x + 1, y), |
|
578 |
* (x, y + 1), (x + 1, y + 1). Si los pixeles x + 1 o y + 1 se salen del raster de origen |
|
579 |
* se tomar? x e y. |
|
580 |
* @param x Coordenada X del pixel inicial |
|
581 |
* @param y Coordenada Y del pixel inicial |
|
582 |
* @param band N?mero de banda. |
|
583 |
* @return Kernel solicitado en forma de array. |
|
584 |
*/ |
|
585 |
private double[] getKernelDouble(int x, int y, int band) { |
|
586 |
double[] d = new double[4]; |
|
587 |
d[0] = getElemDouble(y, x, band); |
|
588 |
int nextX = ((x + 1) >= getWidth()) ? x : (x + 1); |
|
589 |
int nextY = ((y + 1) >= getHeight()) ? y : (y + 1); |
|
590 |
d[1] = getElemDouble(y, nextX, band); |
|
591 |
d[2] = getElemDouble(nextY, x, band); |
|
592 |
d[3] = getElemDouble(nextY, nextX, band); |
|
593 |
return d; |
|
594 |
} |
|
595 |
|
|
596 |
/** |
|
290 | 597 |
* Ajusta el raster al ancho y alto solicitado ajustando con una interpolaci?n de distancia inversa. |
291 | 598 |
* Asigna el valor de un pixel en funci?n inversa de la distancia. |
292 | 599 |
* |
293 | 600 |
* @param w Nuevo ancho |
294 | 601 |
* @param h Nuevo alto |
295 | 602 |
*/ |
296 |
public abstract RasterBuffer adjustRasterInverseDistanceInterpolation(int w, int h, int[] bands); |
|
603 |
private RasterBuffer adjustRasterInverseDistanceInterpolation(int w, int h) { |
|
604 |
return this; |
|
605 |
} |
|
297 | 606 |
|
298 | 607 |
/** |
299 | 608 |
* Ajusta el raster al ancho y alto solicitado ajustando con una interpolaci?n de spline bicubica. |
300 | 609 |
* @param w Nuevo ancho |
301 | 610 |
* @param h Nuevo alto |
302 | 611 |
*/ |
303 |
public abstract RasterBuffer adjustRasterBicubicSplineInterpolation(int w, int h, int[] bands); |
|
612 |
private RasterBuffer adjustRasterBicubicSplineInterpolation(int w, int h) { |
|
613 |
return this; |
|
614 |
} |
|
304 | 615 |
|
305 | 616 |
/** |
306 | 617 |
* Ajusta el raster al ancho y alto solicitado ajustando con una interpolaci?n BSpline. |
307 | 618 |
* @param w Nuevo ancho |
308 | 619 |
* @param h Nuevo alto |
309 | 620 |
*/ |
310 |
public abstract RasterBuffer adjustRasterBSplineInterpolation(int w, int h, int[] bands); |
|
621 |
private RasterBuffer adjustRasterBSplineInterpolation(int w, int h) { |
|
622 |
return this; |
|
623 |
} |
|
311 | 624 |
|
312 | 625 |
/* |
313 | 626 |
* (non-Javadoc) |
314 | 627 |
* @see org.gvsig.fmap.driver.IBuffer#getNoDataValue() |
315 | 628 |
*/ |
316 |
public double getNoDataValue(){ |
|
629 |
public double getNoDataValue() {
|
|
317 | 630 |
return noDataValue; |
318 | 631 |
} |
319 | 632 |
|
... | ... | |
321 | 634 |
* (non-Javadoc) |
322 | 635 |
* @see org.gvsig.fmap.driver.IBuffer#getByteNoDataValue() |
323 | 636 |
*/ |
324 |
public byte getByteNoDataValue(){ |
|
637 |
public byte getByteNoDataValue() {
|
|
325 | 638 |
return (byte)noDataValue; |
326 | 639 |
} |
327 | 640 |
|
... | ... | |
379 | 692 |
*/ |
380 | 693 |
public abstract IBuffer cloneBuffer(); |
381 | 694 |
|
695 |
/** |
|
696 |
* Ajusta el ?rea del grid a un ancho y un alto dado en pixeles. Este ajuste se har? |
|
697 |
* en relaci?n a un m?todo de interpolaci?n definido en el par?metro. |
|
698 |
* @param w Ancho de la nueva imagen. |
|
699 |
* @param h Alto de la nueva imagen. |
|
700 |
* @param interpolation M?todo de interpolaci?n que se usar? en el ajuste. |
|
701 |
*/ |
|
702 |
public RasterBuffer getAdjustedWindow(int w, int h, int interpolationMethod) { |
|
703 |
if(w == getWidth() && h == getHeight()) |
|
704 |
return this; |
|
705 |
RasterBuffer rasterBuf = null; |
|
706 |
switch(interpolationMethod) { |
|
707 |
case IQueryableRaster.INTERPOLATION_NearestNeighbour: |
|
708 |
rasterBuf = adjustRasterNearestNeighbourInterpolation(w, h); |
|
709 |
break; |
|
710 |
case IQueryableRaster.INTERPOLATION_Bilinear: |
|
711 |
rasterBuf = adjustRasterBilinearInterpolation(w, h); |
|
712 |
break; |
|
713 |
case IQueryableRaster.INTERPOLATION_InverseDistance: |
|
714 |
rasterBuf = adjustRasterInverseDistanceInterpolation(w, h); |
|
715 |
break; |
|
716 |
case IQueryableRaster.INTERPOLATION_BicubicSpline: |
|
717 |
rasterBuf = adjustRasterBicubicSplineInterpolation(w, h); |
|
718 |
break; |
|
719 |
case IQueryableRaster.INTERPOLATION_BSpline: |
|
720 |
rasterBuf = adjustRasterBSplineInterpolation(w, h); |
|
721 |
break; |
|
722 |
} |
|
723 |
return rasterBuf; |
|
724 |
} |
|
725 |
|
|
382 | 726 |
/** |
383 | 727 |
* Calcula el m?nimo y el m?ximo del histograma previamente. |
384 | 728 |
* @return double[] con el m?nimo y el m?ximo. |
trunk/libraries/libRaster/src/org/gvsig/raster/dataset/io/GdalWriter.java | ||
---|---|---|
575 | 575 |
} |
576 | 576 |
} |
577 | 577 |
|
578 |
|
|
579 |
|
|
580 |
|
|
581 | 578 |
/** |
582 | 579 |
* Realiza la escritura de datos con los datos que le pasa el cliente. |
583 | 580 |
* @throws IOException |
... | ... | |
586 | 583 |
if (dataWriter == null) |
587 | 584 |
throw new IOException("No se ha obtenido un objeto de entrada para la escritura valido."); |
588 | 585 |
|
589 |
this.write(GeoRasterWriter.MODE_DATAWRITE);
|
|
586 |
write(GeoRasterWriter.MODE_DATAWRITE); |
|
590 | 587 |
|
591 | 588 |
if(driverParams.getParamById("tfw").defaultValue.equals("true")) { |
592 | 589 |
if(extent != null) |
Also available in: Unified diff