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
How to use histogram enhancement in yaml files? #1879
Comments
Sorry about that. This should work (based on the linked to documentation for crude stretch): - name: hist_eq
method: !!python/name:satpy.enhancements.stretch
kwargs:
stretch: histogram This ends up calling this method in the trollimage package: https://github.com/pytroll/trollimage/blob/5aeef5a2534442434cb00b0a9e091bf72a222130/trollimage/xrimage.py#L1234-L1244 Which takes an additional "approximate" boolean argument which when True will perform a faster approximate histogram equalization. It defaults to False. You can provide this in the YAML at the same level as the |
I tried to use this enhancement for a compositors, but it seems that it uses histogram enhancement for the entire picture. How do I use it for each channel? Is it can be created in my yaml file? yam file:
|
You're correct, the histogram enhancement applies to the entire data array. To apply it per channel you would likely have to write your own compositor python code to apply the enhancement inside the compositor and then make an RGB from that. It isn't incredibly difficult if you are comfortable with python, but it does require more customization than you're looking for. I'm done something kind of similar as far as pre-enhancing a single composite but this was in my own project "polar2grid": I'm not sure how useful that would be for you. Could you explain what type of product you are making? Wouldn't applying histogram equalization to an RGB make it non-physical? I mean, the colors in the RGB don't actually mean much from image to image. Mostly I'm just curious. |
I just want to make the pictures more visible. I use modis channel 1, 2, and 31 , and each channel is histogram equalized to draw smoke. |
In that case, my original suggestions still stand (custom compositor or custom enhancement python code). That, or you define a "crude" or "linear" stretch in your enhancement for your RGB which allows for per-channel min and max limits. |
Hello David: Sorry to disturb you on the weekend. I tried to use the method you recommended, but I don't know how to use SingleEnhancedBandCompositor.
When I tried to use SingleBandCompositor, it alse failed
May you show me an example about SingleEnhancedBandCompositor? Then if I get a
or
Thank you for responce. Haidao |
"It failed" how? Do you have error messages? The output isn't what you expect? How did it fail? I assumed you wanted to do this all in YAML, sorry. If you're ok doing this all in python then we can probably make something up without having to use the extra classes. It isn't as pretty but it can be done all in one python script so that's nice. |
I want to use satpy to create a custom three-channel compositor, and each channel is histogram equalized. You told me that you can use
But when I used the script, I failed at this step.
Error messages:
I guess I used Thank you for your help these days. |
So my original suggestion for using from satpy.writers import to_image
from satpy.composites import GenericCompositor
r_band = to_image(scn["1"])
r_band.stretch_hist_equalize(True)
g_band = to_image(scn["2"])
g_band.stretch_hist_equalize(True)
b_band = to_image(scn["3"])
b_band.stretch_hist_equalize(True)
comp = GenericCompositor("test1")
test1 = comp((r_band.data, g_band.data,b_band.data))
img = to_image(test1)
img.save("test1.tif") Note that There are slightly different ways to do this involving YAML but this should work...I think. |
Thank you! It works! But when I want to use it to generate true_color without histogram enhancement, the image is completely white.
And I tried to use modifiers:
It shows:
|
One step at a time:
|
Thank you for your reminder. When I use modified data, if I load modified data and normal data separately, two channels with the same name will appear. How can I choose the modified data to create RGB images? such as :
It shows:
How to select the corrected channel 1 or the default channel 1? Thank you again. |
You can use that same DataQuery object to do |
Thank you for your help these days! ^_^ |
No problem. I think your original issue has been solved, but if you have further questions feel free to comment here or make a new issue. |
Dear:
I checked the satpy documentation and found that it supports histogram enhancement. But I did not find an example or introduction. How can I use histogram enhancement in yaml files or in python codes?
url:
https://satpy.readthedocs.io/en/stable/enhancements.html?highlight=Histogram#histogram
Thank you.
Haidao
The text was updated successfully, but these errors were encountered: