圖像金字塔 簡單來說就是 自下而上圖像一步一步縮小 1 高斯金字塔(涉及高斯分佈) 向下採樣(縮小,對金字塔來說是自下向上) 第一步: 高斯濾波去噪 第二部:將偶數行和列去掉 向上採樣(放大,對金字塔來說是自上向下) 第一步:在每個方向上擴大兩倍,新增的行和列填充0 第二步:利用之前同樣的內核進行捲 ...
Geomtery子類圖
創建Geometry
GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory();
// 點
Coordinate coord = new Coordinate(1, 1);
Point point = geometryFactory.createPoint(coord);
// 線
Coordinate[] coordinates = new Coordinate[] {new Coordinate(0, 2), new Coordinate(2, 0), new Coordinate(8, 6) };
LineString line = geometryFactory.createLineString(coordinates);
// 面
Coordinate[] coords = new Coordinate[] {new Coordinate(4, 0), new Coordinate(2, 2), new Coordinate(4, 4), new Coordinate(6, 2), new Coordinate(4, 0) };
LinearRing ring = geometryFactory.createLinearRing(coords);
LinearRing holes[] = null; // use LinearRing[] to represent holes
Polygon polygon = geometryFactory.createPolygon(ring, holes);
// 圓
CurvedGeometryFactory curvedFactory = new CurvedGeometryFactory(geometryFactory, Double.MAX_VALUE);
CoordinateSequence coords = PackedCoordinateSequenceFactory.DOUBLE_FACTORY.create(new double[] {10, 14, 6, 10, 14, 10}, 2);
CircularString arc = (CircularString) curvedFactory.createCurvedGeometry(coords);
Geometry轉換坐標系
CoordinateReferenceSystem sourceCRS = CRS.decode("EPSG:4326");
CoordinateReferenceSystem targetCrs = CRS.decode("EPSG:4490");
boolean lenient = true; // allow for some error due to different datums
MathTransform transform = CRS.findMathTransform(sourceCRS, targetCrs, lenient);
Geometry geometry2 = JTS.transform(geometry, transform);
Geometry方法
// 空間判斷
// 不相交
boolean disjoint = geometry.disjoint(geometry2);
// 相交
boolean intersects = geometry.intersects(geometry2);
// 相切,內部不相交
boolean touches = geometry.touches(geometry2);
// 被包含
boolean within = geometry.within(geometry2);
//包含,只針對幾何內部而言,不計算邊界
boolean contains = geometry.contains(geometry2);
//覆蓋,不區分集合邊界與內部
boolean covers = geometry.covers(geometry);
//相交,不能是相切或者包含
boolean crosses = geometry.crosses(geometry);
//相交
boolean overlaps = geometry.overlaps(geometry2);
// 兩個幾何的空間關係
IntersectionMatrix relate1 = geometry.relate(geometry2);
//空間計算
//求交集
Geometry intersection = geometry.intersection(geometry2);
//求並集
Geometry union = geometry.union(geometry);
//geometry-交集
Geometry difference = geometry.difference(geometry2);
// 並集-交集
Geometry symDifference = geometry.symDifference(geometry);
// 幾何緩衝生成新幾何
Geometry buffer1 = geometry.buffer(2);
// 生成包含幾何的最小凸多邊形
Geometry convexHull = geometry.convexHull();
// 兩個幾何的最小距離
double distance = geometry.distance(geometry);
// 面積
double area = geometry.getArea();
//幾何類型
String geometryType = geometry.getGeometryType();
// 邊界
Geometry boundary = geometry.getBoundary();
// 獲取中心點
Point centroid = geometry.getCentroid();
Geometry 與 WKT 轉換
// geometry轉wkt
//方法一
WKTWriter2 wktWriter2 = new WKTWriter2()
String wkt = wktWriter2.write(geometry)
//方法二
String text = geometry.toText();
// wkt轉geometry
WKTReader2 wktReader2 = WKTReader2()
Point point = (Point) wktReader2.read("POINT (1 1)");
LineString line = (LineString) wktReader2.read("LINESTRING(0 2, 2 0, 8 6)");
Polygon polygon = (Polygon) wktReader2.read("POLYGON((20 10, 30 0, 40 10, 30 20, 20 10))");
pom.xml
<dependencies>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-shapefile</artifactId>
<version>${geotools.version}</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-epsg-hsql</artifactId>
<version>${geotools.version}</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>osgeo</id>
<name>OSGeo Release Repository</name>
<url>https://repo.osgeo.org/repository/release/</url>
<snapshots><enabled>false</enabled></snapshots>
<releases><enabled>true</enabled></releases>
</repository>
<repository>
<id>osgeo-snapshot</id>
<name>OSGeo Snapshot Repository</name>
<url>https://repo.osgeo.org/repository/snapshot/</url>
<snapshots><enabled>true</enabled></snapshots>
<releases><enabled>false</enabled></releases>
</repository>
</repositories>