Appearance
灰度图处理
依赖
xml
<dependency>
<groupId>com.geoviswtx</groupId>
<artifactId>geoviswtx-utils-img</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
使用
java
GrayScaleImgUtils.creatGrayImgToInputStream(array[0], true)
代码示例
java
@Test
void testGfsImg() throws Exception {
NetcdfFile netcdfFile
= NetcdfFile.openInMemory("..\\dat\\1980s_nutrients.nc");
String elem = "Temperature_surface";
Variable variable = netcdfFile.findVariable(elem);
Array read = variable.read();
float[][][] array = (float[][][]) read.copyToNDJavaArray();
try(ByteArrayInputStream in = GrayScaleImgUtils.creatGrayImgToInputStream(array[0], true,
(y, x) -> (double) array[0][y][x] - 273.15);
FileOutputStream out = new FileOutputStream("target\\" + elem + ".png"))
{
IOUtils.copy(in, out);
}
}