[QGIS-Developer] Custom Contrast Enhancement Function

gordonbe gordon at axelspace.com
Mon Mar 22 02:30:35 PDT 2021


My problem is that the contrast enhancement method I have in mind is quite
specific and relies on different statistics than the current functions like
StretchAndClipToMinimumMaximum, i.e. I'd like to use a method that also
relies on the mean value of the image.

I can see from the docs that there is a UserDefinedEnhancement option,
however I'm not quite clear on how to implement it.

For more detail on the code I'm using, please see my related StackOverflow
post here
https://stackoverflow.com/questions/66664148/pyqgis-custom-contrast-enhancement-function
(apologies for dual posting, I haven't received any feedback on
StackOverflow and if I get an answer here then I will delete the original
post to avoid duplication).

My approach is to write a new CustomFunction class that inherits the
QgsContrastEnhacementFunction where I can override the `enhance` method with
my own algorithm. This makes sense in my head but it doesn't work in
practice, the output appears black. Please let me know if I'm missing
something, or if pyQGIS simply doesn't support any alternative contrast
enhancement methods to do the currently hardcoded methods.



--
Sent from: http://osgeo-org.1560.x6.nabble.com/QGIS-Developer-f4099106.html


More information about the QGIS-Developer mailing list