Conversation
|
@xinluo2018 can you explain what the problems are? Otherwise, I don't know if this work solves them. |
|
ok, i found the function show() couldn't plot rgb image if the color interpretation information is missing in the image, then we fixed it that is, when the color information is missing for multi-bands image, the first three bands are regarded the RGB bands, like the qgis software. |
rasterio/plot.py
Outdated
|
|
||
| except KeyError: | ||
| arr = source.read(1, masked=True) | ||
| arr = source.read((3,2,1), masked=True) |
There was a problem hiding this comment.
why do you assume that bands are store as BGR ?
There was a problem hiding this comment.
This is from our experience in remote sensing application, that is, if the remote sensing image contains multiple bands, the bands are usually stored by ascending order of the wavelength of bands. The BGR wavelengths are: ~460nm, ~530nm, ~580nm, therefore for a multibands image we set the default index (3,2,1) for the color composition, thus mostly the color composition is the true color composition rather than by setting the default index of (1,2,3).
moreover, if the image bands are not stored as BGR, our revision also at least show the multibands image as a color composite image, while the previous script only show the multibands image as a grey image.
There was a problem hiding this comment.
we add a new feature for image histogram stretching, this feature is used by an optional parameter for users, which will make the image visualization better. i frequently use it for image visualization in my experiment.
There was a problem hiding this comment.
This is from our experience in remote sensing application, that is, if the remote sensing image contains multiple bands, the bands are usually stored by ascending order of the wavelength of bands. The BGR wavelengths are: ~460nm, ~530nm, ~580nm, therefore for a multibands image we set the default index (3,2,1) for the color composition, thus mostly the color composition is the true color composition rather than by setting the default index of (1,2,3).
This is a pretty heavy assumption... which after 15years working with Remote Sensing data, I would not make myself ;-)
if the image bands are not stored as BGR, our revision also at least show the multibands image as a color composite image, while the previous script only show the multibands image as a grey image.
Which is why I think adding an indexes= options might be a better solution
There was a problem hiding this comment.
that is also ok, we add a new 'indexes=' options, and the user can specify the bands for color composite when visualize the multibands image. Hope you can check my code again, thanks.
|
I feel that this PR complexity the show function and make assumption about the data. Maybe adding an |
|
Have you tried this out, @vincentsarago? Does it do what it advertises? @xinluo2018 I will try this out, but first I need to make a 1.4.2 release. |
|
@sgillies I did not I'll try tomorrow |
|
hi, how about the modified code, could you merge our modifications, that the new function could be used in the new release version of rasterio, thanks. |
|
@xinluo2018 I am sorry for the delay and I apologize. I am in favor of this and have several suggestions to make. |
sgillies
left a comment
There was a problem hiding this comment.
@xinluo2018 thank you for the contribution! I have a couple of requests.
| """ | ||
| arr_hist = np.nanpercentile(np.array(arr), (clip_percent, 100 - clip_percent)) | ||
| arr = (arr - arr_hist[0]) / (arr_hist[1] - arr_hist[0]) | ||
| arr = np.clip(arr, 0, 1) |
There was a problem hiding this comment.
Is it necessary to clip the array? Is it not ensured by the math on the line above?
There was a problem hiding this comment.
For rgb image show, it is not necessary, while for the single-band image show, clip the array is necessary for better visualization. the test sample can be found at: https://github.com/xinluo2018/rasterio/blob/test/test.ipynb.
We have made the related modifications by following your other suggestions.
|
happy to be 1 of 158 developers ^_^ |
we found the show function has some problems in ploting the rgb image, thus we fixed it.