Giter Club home page Giter Club logo

daltonize's People

Contributors

joergdietrich avatar spencersutton avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

daltonize's Issues

Memory Error on large images

I know this is an old repo but this is still being used by several developers (including me).

I noticed that on a 2GB linux machine , MemoryError is raised when converting a 2-3MB image (3933 x 5906 pixels in size). Here is a truncated error message.

  File "./<app>/daltonize.py", line 132, in simulate_from_image
    rgb = np.asarray(img, dtype=float)
  File "/root/.cache/pypoetry/virtualenvs/<path>/lib/python3.6/site-packages/numpy/core/_asarray.py", line 85, in asarray
    return array(a, dtype, copy=False, order=order)
MemoryError: Unable to allocate 532. MiB for an array with shape (3933, 5906, 3) and data type float64

This is very weird that for a 3MB file, it requires a large 532MB amount of memory.

Related line on this repo: https://github.com/joergdietrich/daltonize/blob/master/daltonize.py#L79

Broken simulation and daltonization with np.float16 and numpy >= 1.21.0

On my Ubuntu 20.04 with Python 3.8.10 and numpy 1.21.3 I always get black images out of the simulation function (all values are zero). numpy 1.20.3 works fine, the problem started with numpy 1.21.0.

The guilty part is transform_colorspace, where the np.einsum("ij, ...j", mat, img, dtype=np.float16, casting="same_kind") always returns 0 when given rgb2lms as input, unless dtype is changed back to np.float32. As a consequence this also breaks the daltonization, which becomes a noop.

I'm not sure if this is actually a numpy bug, but an alternative solution is to return img @ mat.T, which is equivalent to the einsum thanks to numpy broadcasting rules, but still works with float16. It may also be a bit faster.

Going back to float32 might be a safer choice too!

Einstein sum error

I get the following error when I run the program on a 800x600 PNG image:

ValueError: operand 0 did not have enough dimensions to match the broadcasting, and couldn't be extended because einstein sum subscripts were specified at both the start and end

Elementwise comparison warnings

/home/joerg/src/daltonize/daltonize.py:251: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
  if color == 'none':
/home/joerg/src/daltonize/daltonize.py:316: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
  if color == 'none':
/home/joerg/applications/anaconda3/lib/python3.6/site-packages/matplotlib/lines.py:1182: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
  if self._markeredgecolor != ec:
/home/joerg/applications/anaconda3/lib/python3.6/site-packages/matplotlib/lines.py:1206: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
  if self._markerfacecolor != fc:

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.