Coder Social home page Coder Social logo

Comments (16)

maximlt avatar maximlt commented on June 2, 2024

HoloViews has the clim_percentile plot option but that only applies to plot types that inherit from ColorbarPlot, while RGBPlot inherits from LegendPlot. @ahuang11 I'd say we should first add this plot option to HoloViews? To eventually expose it in hvPlot, where I'd say robust would be a good choice given that robust=True would be already familiar to Xarray users.

from hvplot.

ahuang11 avatar ahuang11 commented on June 2, 2024

I was looking at https://github.com/holoviz/holoviews/blob/6aa6c9ddb7c9308531753efae41cbd0873c975a3/holoviews/plotting/bokeh/raster.py#L134 and I'm not sure there's a way to add clim_percentile to RGBPlot without updating Bokeh too.

I tried doing:

        if self.clim_percentile:
            low, high = 0, 1
            style["color_mapper"] = LinearColorMapper(low=low, high=high)
AttributeError [Call holoviews.ipython.show_traceback() for details]
unexpected attribute 'color_mapper' to ImageRGBA, possible attributes are anchor, decorations, dh, dh_units, dilate, dw, dw_units, global_alpha, image, js_event_callbacks, js_property_callbacks, name, origin, subscribed_events, syncable, tags, x or y

I also tried doing:

        if self.clim_percentile:
            low, high = np.nanpercentile(img, (2, 98))
            img[img < low] = low
            img[img > high] = high

But it doesn't seem to work
image

from hvplot.

ahuang11 avatar ahuang11 commented on June 2, 2024

Thoughts about having this in hvPlot?
holoviz/holoviews#6137

I don't have a strong preference, but I do want to have a way forward.

from hvplot.

maximlt avatar maximlt commented on June 2, 2024

I also don't have strong preference :)

from hvplot.

Hoxbro avatar Hoxbro commented on June 2, 2024

I also don't have strong preference 🙃

from hvplot.

philippjfr avatar philippjfr commented on June 2, 2024

I'm -1 on adding this anywhere. Taking percentiles of RGB values just does not make sense to me.

from hvplot.

ahuang11 avatar ahuang11 commented on June 2, 2024

If that's the case, how should users address this?

The initial goal was that I wanted to write a demo of how you can explore satellite imagery with hvplot easily, but then I encountered the issue that robust/clim_percentile was not exposed.

If robust/clim_percentile isn't implemented, its a tad tedious for the user to have to manually implement it for satellite imagery vs typing robust=True.

Would you prefer it be an operation? E.g. Clip?

from hvplot.

philippjfr avatar philippjfr commented on June 2, 2024

Will have to look at it.

from hvplot.

philippjfr avatar philippjfr commented on June 2, 2024

Yeah, looking at this dataset the values are not R G B values they are raw reflectance values for different spectra from a satellite. Visualizing them using an RGB element without first processing these values is simply incorrect. So the only thing I can imagine doing is providing some operation in geoviews.

from hvplot.

philippjfr avatar philippjfr commented on June 2, 2024

https://ecampusontario.pressbooks.pub/remotesensing/chapter/chapter-5-visualization-and-manipulation-of-satellite-images/

from hvplot.

philippjfr avatar philippjfr commented on June 2, 2024

Based on my reading of that the transformation is quite simple, you divide the red green blue values 2**8 and then cast to uint8.

from hvplot.

philippjfr avatar philippjfr commented on June 2, 2024

Alternatively you can also apply histogram equalization.

from hvplot.

philippjfr avatar philippjfr commented on June 2, 2024

Hmm, the division thing doesn't work.

from datashader.transfer_functions import eq_hist
hv.RGB(eq_hist(da.data)[0].transpose([1, 2, 0])).opts(width=600)

bokeh_plot - 2024-03-02T112323 123

from hvplot.

philippjfr avatar philippjfr commented on June 2, 2024
hv.RGB((da / (2**2)).clip(0, 255).astype(np.uint8).data.transpose([1, 2, 0])).opts(width=600)

bokeh_plot - 2024-03-02T112755 242

from hvplot.

philippjfr avatar philippjfr commented on June 2, 2024

Okay, I've come around I'd be okay with a two-pronged approach, we implement the robust semantics in hvPlot and then HoloViews appropriately clips the data.

from hvplot.

ahuang11 avatar ahuang11 commented on June 2, 2024

Philipp found the actual _rescale_imshow_rgb robust usage in xarray here

from hvplot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.