On my OS-X dev system, when I issue this BES command:
I get a geotiff file that's understood by UDig and I can make a picture of the geotiss on my screen (attached).
But when I issue this BES command:
I get back a jpeg2000 image (attached) that appears to be a uniform grey rectangle.
Slav, Please take a look at this and see if it's old and should be closed or still a problem and should be investigated. Don't let this derail your current work - I just didn't want it to be lost when it came up in my search. (I noticed that you were not a 'Developer' on this 'Project,' so you might not have seen it in your searches.)
Take a look at the two screen shots I added today (2019-02-25). These are from geotiff data - so they are NOT jp2k files. However, they show somethign interesting about rendering these 'science data' files. The missing data are often indicated by very large or very small values (e.g., 9999) and rendering code often doesn't know this. Since JP2k is a JPEG file, it's 'rendered' and if it assumes the data are between -16 and 9999 we'll get a picture, with most of the variation between -16 and 16 lost. When I reset the range from the automatically chosen values to -16 to 16, all the sudden we get a much better picture. Maybe that's what was happening with the JP2k response?
One way to fix this would be to have the fileout_gdal code look for missing values and then set the data range to be something that does not include that. We might have to write a function that finds the min & max values for an array and (optionally) excludes a value (e.g. the missing data value) from that computation.
Output GeoTiff and Jpeg2000 files are valid and visually can be improved without changing code as following:
1. Open image with Preview.app in MacOS. Click Tools ->Adjust Color... -> Auto Level. In this case we get black and wight image.
2. Use gdal_translate:
gdal_translate -scale in.tif out.tif
gdal_translate -scale in.jp2 in.jp2
In this case we get grey levels.