Closed githubhanjunjun closed 3 years ago
@githubhanjunjun because you are using jpeg compression with nodata. Fix: use internal mask or lossless compression
@githubhanjunjun because you are using jpeg compression with nodata. Fix: use internal mask or lossless compression
Thank you very much for your answer.
@vincentsarago 's suggestion was to change your data not your code. I think the point is that there's nothing you can do about the black portions because the data was saved with lossy compression and without an internal mask.
- 'lossless compression' means set 'nodata=None', right?
No, I mean: I'm assuming your data is compressed using JPEG. the back artefacts are created because of a nodata (0
) being compressed using non-lossless compression (jpeg). So if you are asking if you should create your input file without nodata value set: Yes.
- 'use internal mask' means use the mask in the code below, right? tile, mask = cog.tile(x, y, z, indexes=indexes, tilesize=tilesize, nodata=nodata, resampling_method=resampling)
No I meant: create your input file using internal mask, not nodata value
- 'lossless compression' means set 'nodata=None', right?
No, I mean: I'm assuming your data is compressed using JPEG. the back artefacts are created because of a nodata (
0
) being compressed using non-lossless compression (jpeg). So if you are asking if you should create your input file without nodata value set: Yes.
- 'use internal mask' means use the mask in the code below, right? tile, mask = cog.tile(x, y, z, indexes=indexes, tilesize=tilesize, nodata=nodata, resampling_method=resampling)
No I meant: create your input file using internal mask, not nodata value
I see what you mean. Thank you very much for your answer. Please forgive me that my English is not very good. I can get better results by setting 'noData =None'
@vincentsarago 's suggestion was to change your data not your code. I think the point is that there's nothing you can do about the black portions because the data was saved with lossy compression and without an internal mask.
Thank you for your reply. My data is indeed JPEG compressed
not sure where your input data is from but if you have access to the uncompressed
data you could create a COG with JPEG compression and internal mask
using rio-cogeo
$ rio cogeo create myinput.tif mycog.tif -p jpeg --add-mask
if you want to use GDAL commands (with the new COG driver), I think you'll need to first translate the nodata value to a mask band
not sure where your input data is from but if you have access to the data you could create a COG with JPEG compression and internal mask
uncompressed
using rio-cogeo
$ rio cogeo create myinput.tif mycog.tif -p jpeg --add-mask
if you want to use GDAL commands (with the new COG driver), I think you'll need to first translate the nodata value to a mask band
My data was generated by ODM, and I compressed the results with JPEG. I can get rid of the compression code. Thank you very much for your advice
1.Version: rio-tiler2.0.0 2. API : cog.tile() 3. code: indexes = non_alpha_indexes(cog.dataset) # indexes = (1, 2, 3) nodata = 0 resampling="nearest" tile, mask = cog.tile(x, y, z, indexes=indexes, tilesize=tilesize, nodata=nodata, resampling_method=resampling) How can I solve this problem? Please help me.