Giter Site home page Giter Site logo

Comments (9)

martinRenou avatar martinRenou commented on May 16, 2024

Thanks for opening an issue!

I am surprised I did not use this.ctx.getImageData in the first place. I hope I did not have a good reason to not do so. I totally agree with your implementation, if you can come up with a PR I would be happy to merge it! Also removing the Pillow dependency is good.

Though I think an even more general solution is to use the serializers and traittypes from https://github.com/vidartf/ipydatawidgets

I disagree with this because I don't want ipycanvas to depend on another widgets library. Having users to install one labextension/nbextension is already quite difficult, so asking them to install two of them in order for ipycanvas to work is too much IMO.

from ipycanvas.

martinRenou avatar martinRenou commented on May 16, 2024

It would be nice to compare performances between your solution and the previous one though. I might have used the toBlob for performances purpose, but I am not sure.

from ipycanvas.

ianhi avatar ianhi commented on May 16, 2024

I disagree with this. I don't want to depend on another widgets library. Having users to install one labextension/nbextension is already quite difficult, so asking them to install two of them in order for ipycanvas to work is too much IMO.

100% that installing more than one labextension is no good. Though I don't think that would be necessary. It's not clear from the name but that is broken into separate packages so you can have the traittype and serializers without requiring any jupyter labextension install steps. There is 1 python package and two different js packages. 1 of them is the extension and widgets, and the other is just the serializers. (related is this issue jupyter-widgets/traittypes#21)

It would be nice to compare performances between your solution and the previous one though. I might have used the toBlob for performances purpose, but I am not sure.

Maybe size was your reason? see: https://stackoverflow.com/a/34924715/835607. given the differences in size maybe it's best to leave as is?

I think that the ndarray traittype gets around by offering a compression option https://github.com/vidartf/ipydatawidgets/blob/69eebeb5647d58dec6bf459d424727cb23cce8ab/packages/serializers/src/ndarray.ts#L167

from ipycanvas.

ianhi avatar ianhi commented on May 16, 2024

Is performance also the reason you have sync_image_data default to False?

from ipycanvas.

martinRenou avatar martinRenou commented on May 16, 2024

Though I don't think that would be necessary. It's not clear from the name but that is broken into separate packages so you can have the traittype and serializers without requiring any jupyter labextension install steps. There is 1 python package and two different js packages. 1 of them is the extension and widgets, and the other is just the serializers. (related is this issue jupyter-widgets/traittypes#21)

Good catch! Then I agree we could depend on the Python package to make things modular :)

Maybe size was your reason? see: https://stackoverflow.com/a/34924715/835607. given the differences in size maybe it's best to leave as is?

Yes that might have been the reason for not using getImageData directly. Although if you think the compression that happens during the blob transformation is a problem (loss of data?) we should maybe consider using getImageData instead.

Is performance also the reason you have sync_image_data default to False?

Indeed.

from ipycanvas.

martinRenou avatar martinRenou commented on May 16, 2024

Is performance also the reason you have sync_image_data default to False?

I might be wrong, but I thought that in most of the cases, people would not need to retrieve the image as a NumPy array.

from ipycanvas.

ianhi avatar ianhi commented on May 16, 2024

Although if you think the compression that happens during the blob transformation is a problem (loss of data?) we should maybe consider using getImageData instead

I think PNG compression is lossless and the conversions that you're using result in PNG compression so that shouldn't be an issue. If you wanted an intermediate to using ipydatawidgets then you can trade the Pillow dep for a typescript one (pako) (like this ianhi/ipysegment@0127f5b) and use the python builtin zlib. So I guess in the end it's kind of a wash.

I might be wrong, but I thought that in most of the cases, people would not need to retrieve the image as a NumPy array.

That also rings true

from ipycanvas.

martinRenou avatar martinRenou commented on May 16, 2024

Should we close this?

from ipycanvas.

ianhi avatar ianhi commented on May 16, 2024

Probably. Feel free to re-open if you ever want to change your image data serialization strategy, but what you have now works, so there's no real need to change it.

from ipycanvas.

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.