Skip to content
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

Halftone Encoding Algorithm is Broken #37

Closed
8bitben opened this issue Mar 28, 2022 · 1 comment · Fixed by #38
Closed

Halftone Encoding Algorithm is Broken #37

8bitben opened this issue Mar 28, 2022 · 1 comment · Fixed by #38

Comments

@8bitben
Copy link

8bitben commented Mar 28, 2022

When using 'halftone' algorithm for image encoding, a Python error is present:

⏳ Applying halftone dithering to image...
Traceback (most recent call last):
  File "/Projects/cat_printer_interface/catprinter/print-modified.py", line 80, in <module>
    custom()
  File "/Projects/cat_printer_interface/catprinter/print-modified.py", line 48, in custom
    data = cmds_print_img(bin_img, dark_mode=True)
  File "/Projects/cat_printer_interface/catprinter/catprinter/cmds.py", line 167, in cmds_print_img
    data += cmd_print_row(row)
  File "/Projects/cat_printer_interface/catprinter/catprinter/cmds.py", line 127, in cmd_print_row
    encoded_img = run_length_encode(img_row)
  File "/Projects/cat_printer_interface/catprinter/catprinter/cmds.py", line 101, in run_length_encode
    if val == last_val:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
✅ Done.

$ python --version Python 3.10.2

rbaron added a commit that referenced this issue Mar 28, 2022
The contributed algo (#14) seems to assume images with 3 channels, but we are working with
grayscale images here.

Fixes #37
@rbaron
Copy link
Owner

rbaron commented Mar 28, 2022

Thanks for filing the issue @8bitben. I took a quick look and #38 should fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants