#4647 closed defect (fixed)
GDALRasterPolygonEnumerator does not merge polygons correctly when nConnectedness = 8
Reported by: | ctoney | Owned by: | warmerdam |
---|---|---|---|
Priority: | normal | Milestone: | 1.9.1 |
Component: | Algorithms | Version: | 1.9.0 |
Severity: | normal | Keywords: | Raster Polygon Enumerator |
Cc: | Kyle Shannon |
Description
When nConnectedness = 8 (diagonal pixels considered connected), GDALRasterPolygonEnumerator does not merge some diagonally connected pixels into the same polygon.
The attached graphic shows two examples of connected pixels that were not merged into a single polygon. In the graphic, yellow and blue pixels have the same value and should be enumerated as polygons when connected diagonally or along sides. All other pixels are masked out from polygon enumeration.
The logic in GDALRasterPolygonEnumerator::ProcessLine is incomplete for nConnectedness = 8. Some additional checks for diagonal connectedness are needed with calls to MergePolygon. The attached file gdalrasterpolygonenumerator_fix.cpp contains the additional checks in ProcessLine - all changes are in lines 188-246. The fixed code has been tested on several examples and seems to work on all possible pixel configurations with diagonal connectedness.
Similar changes are probably needed in gdalrasterfpolygonenumerator.cpp (the version using float buffers).
Attachments (4)
Change History (11)
by , 12 years ago
Attachment: | polygon_enum_8connect_fail.png added |
---|
by , 12 years ago
Attachment: | gdalrasterpolygonenumerator_fix.cpp added |
---|
comment:1 by , 12 years ago
Cc: | added |
---|
comment:2 by , 12 years ago
comment:4 by , 12 years ago
Version: | unspecified → 1.9.0 |
---|
comment:5 by , 12 years ago
Milestone: | → 1.9.1 |
---|---|
Status: | new → assigned |
It would be really nice to have a small test file that demonstrates the problem so we could extend the test suite. See samples in autotest/alg/
I also imagine this needs to be applied to the new floating point copy of the polygonization algorithm.
comment:6 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
by , 12 years ago
Attachment: | polygonize_test.tif added |
---|
comment:7 by , 12 years ago
I've attached a small test file that demonstrates the problem of some diagonally connected polygons not merged. Pixel values are 6 or nodata.
Chris, what version are you using?