Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segmentation contour boundaries off by 1 pixel on two edges #123

Open
przemyslaw-aszkowski opened this issue Nov 29, 2023 · 1 comment
Open

Comments

@przemyslaw-aszkowski
Copy link
Contributor

For segmentation, if you zoom the model output layer close enough, you can see that between segmentation masks for different classes, there is a one-pixel gap, see screenshot:
image

It happens because after stitching the model outputs, the contour is found by the OpenCV (findContours), which finds top-left corner of the contour pixel. Afterwards, it is converted to a polygon layer, which goes through all the contour points, therefore, on the opposite edges, we lose one pixel.

It should be fixed, but I do not have a good idea now on how to do it.

@Saareem
Copy link
Contributor

Saareem commented Nov 30, 2023

I'm implementing raw result raster output for MapProcessorSegmentation so I can use thresholding, argmax and gdal_polygonize on the raw result instead of the default argmax + cv2.findContours. This is something I would have done anyway as some models use probability masks as input.

EDIT: It seems MapProcessorRegression does pretty much what I want, (i.e. the raw probability masks which I could convert to segmentation masks by thresholding), except that there are two layers instead of one. However, my post-processing routine could be easily adapted for that. Still, I'm implementing this as outputting raw segmentation mask is valuable.

But the edge effects are present in the argmaxed output (just full result img as a raster in QGIS, which I have already implemented in a quick and dirty way. Now I'm moving couple of raster functions from MapProcessorSuperresolution to processing_utlis and use those to save the rasters in MapProcessorSegmentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants