Giter Site home page Giter Site logo

hitherdither's People

Contributors

hbldh avatar makew0rld avatar sagerkudrick 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  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  avatar  avatar

hitherdither's Issues

Make Palette handle greyscale

Currently grayscale and BW images does not work very well att all with the palette object. Needs to be implemented.

Failed to install!!!

  • Python version: 3.7.4
  • Operating System: Windows 10

Description

Trying to install but it is showing some errors!

What I Did

C:\Users\akans>pip install git+https://www.github.com/hbldh/hitherdither
Collecting git+https://www.github.com/hbldh/hitherdither
  Cloning https://www.github.com/hbldh/hitherdither to c:\users\akans\appdata\local\temp\pip-req-build-guyhoi6g
  Running command git clone -q https://www.github.com/hbldh/hitherdither 'C:\Users\akans\AppData\Local\Temp\pip-req-build-guyhoi6g'
    ERROR: Command errored out with exit status 1:
     command: 'C:\Anaconda\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\akans\\AppData\\Local\\Temp\\pip-req-build-guyhoi6g\\setup.py'"'"'; __file__='"'"'C:\\Users\\akans\\AppData\\Local\\Temp\\pip-req-build-guyhoi6g\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base pip-egg-info
         cwd: C:\Users\akans\AppData\Local\Temp\pip-req-build-guyhoi6g\
    Complete output (11 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Anaconda\lib\site-packages\setuptools\__init__.py", line 12, in <module>
        from setuptools.extension import Extension
      File "C:\Anaconda\lib\site-packages\setuptools\extension.py", line 7, in <module>
        from setuptools.dist import _get_unpatched
      File "C:\Anaconda\lib\site-packages\setuptools\dist.py", line 16, in <module>
        import pkg_resources
      File "C:\Anaconda\lib\site-packages\pkg_resources.py", line 1479, in <module>
        register_loader_type(importlib_bootstrap.SourceFileLoader, DefaultProvider)
    AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

Creating palette on certain images throws ValueError: zero-size array to reduction operation minimum which has no identity

  • Python version: 3.8
  • Operating System: Windows 10

Description

I attempted to create a palette with a PNG w/ a RGBA paltette converted to a JPEG w/ a RGB palette for dithering using the hitherdither.palette.Palette.create_by_median_cut(img) method.

img = Image.open('phcpd.png')

    img.load()

    background = Image.new("RGB", img.size, (255, 255, 255))

    background.paste(img, mask=img.split()[3])

    background.save('ikasdf.jpg', "JPEG", quality=80)

    img = Image.open('ikasdf.jpg')

    palette = hitherdither.palette.Palette.create_by_median_cut(img)

    img_dithered = hitherdither.ordered.bayer.bayer_dithering(img, palette, [256 / 4, 256 / 4, 256 / 4], order=8)

    img_dithered.save("test.png")

    print(type(img_dithered))

However, this error resulted:

Traceback (most recent call last):
  File "C:/Users/megag/PycharmProjects/SerenityBot/main_PIL_test.py", line 227, in <module>
    dither_test()
  File "C:/Users/megag/PycharmProjects/SerenityBot/main_PIL_test.py", line 27, in dither_test
    palette = hitherdither.palette.Palette.create_by_median_cut(img)
  File "C:\Users\megag\PycharmProjects\SerenityBot\venv\lib\site-packages\hitherdither\palette.py", line 185, in create_by_median_cut
    new_bins += median_cut(bin, dim)
  File "C:\Users\megag\PycharmProjects\SerenityBot\venv\lib\site-packages\hitherdither\palette.py", line 168, in median_cut
    mins = p.min(axis=0)
  File "C:\Users\megag\PycharmProjects\SerenityBot\venv\lib\site-packages\numpy\core\_methods.py", line 44, in _amin
    return umr_minimum(a, axis, None, out, keepdims, initial, where)
ValueError: zero-size array to reduction operation minimum which has no identity

A link to the image is available here: phcpd.png.

Problem installing hitherdither

Hi!
Have a month successfully using your lib. It's awesome and helped me do a lot.
I tried to scale the project a bit, so I relaunched my Python environment.
Screenshot 2020-02-27 at 19 44 00
That what I get now every time I try to install hitherdither all the time.
Could you help me solve this issue?

Incorrect output

I've noticed that images produced with hitherdither are slightly different than those produced with other programs using the same algorithms.

I tested this using Floyd-Steinberg on a solid 50% gray image, which should produce a uniform checkerboard pattern.

Input Output Expected (from PIL)
808080 out mock_output

I've found that by rounding when distributing the quantization error, the above image renders correctly, while others are closer but still different.
ni[yn, xn] += np.round(quantization_error * diffusion_coefficient)
Maybe that's as good as it's gonna get.

Upload Library to Pypi.

This should be available via pypi.

Without an easy dependency option, I would have just lifted the needed code but, it's a bit of a labyrinth in that needed functions are found bouncing around init files etc. Needs to be easier than just writing the functions myself.

Source for Stevenson-Arce?

hitherdither has a matrix for the Stevenson-Arce error diffusion dither, as see here:

"stevenson-arce": (
(2, 0, 32 / 200),
(-3, 1, 12 / 200),
(-1, 1, 26 / 200),
(1, 1, 30 / 200),
(3, 1, 30 / 200),
(-2, 2, 12 / 200),
(0, 2, 26 / 200),
(2, 2, 12 / 200),
(-3, 3, 5 / 200),
(-1, 3, 12 / 200),
(1, 3, 12 / 200),
(3, 3, 5 / 200),
),
}

As noted here:

Stevenson-Arce is designed to work on hexagonal arrays and will obviously give ugly results on regular square pixel images.

And this source describes Stevenson-Arce like this:

Stevenson-Arce:
	
	            *   .  32
	12  .   26  .  30   . 16
        .   12  .  26  .   12  .
	5   .   12  .  12   .  5    / 200

This obviously shows a hexagonal arrangement.

So where did you get your numbers from, or how did you derive them? Do you have any example pictures of what this looks like?

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.