pappersverk / rpi_fb_capture

Capture the Raspberry Pi's framebuffer
Apache License 2.0
11 stars 2 forks source link

Add dithering support for 1-bpp formats #4

Closed luisgabrielroldan closed 4 years ago

luisgabrielroldan commented 5 years ago

As suggested in #1 I did a simple implementation of dithering for the mono formats

fhunleth commented 5 years ago

This is a great addition! Thank you for writing it up and sending the PR over!!

fhunleth commented 5 years ago

FYI - I started a branch so that we could get some unit tests in this project. https://github.com/fhunleth/rpi_fb_capture/tree/dithering_plus_tests. It has a few commits that aren't relevant, but I wanted to let you know the direction I was going before merging and releasing a version with dithering support. One note on the simulator, I'll probably combine sim.c and main.c since they have more shared code than not. I didn't think it would turn out that way in the beginning. I haven't tested anything yet so the code doesn't work (It compiles, though). The next step is to get before and after pictures to populate unit tests. Do you have any 128x64 test pictures?

luisgabrielroldan commented 5 years ago

I like the idea of combine both files, Do you plan to add a command to send the source image to be converted?

What kind of formats you want to use for comparision? I can generate some test pictures.

fhunleth commented 5 years ago

At the moment, I was thinking of replacing the capture logic to return a canned image. That way the tests could call into the existing APIs.

As for formats, I was thinking of using Imagemagick to convert whatever input we had into RGB565 so that it would match the capture format from the Raspberry Pi. Same for the result picture except make it 1 bpp. Another option would be to write a PPM/PBM reader since that's probably the easiest format to code up in Elixir. I haven't checked whether something already exists on hex.pm, though. Given that the needs are simple for this library, I'm leaning to working with raw bitmaps rather than writing any code to deal with proper image formats, but I could change my mind.

luisgabrielroldan commented 4 years ago

Hi @fhunleth . Anything new about this? Tell me how can I help you.

fhunleth commented 4 years ago

Thanks for the reminder. No. Nothing new.

I'm still worried about long term maintainability of the code since there are no regression tests. (My fault, not yours.)

What I'd really like done first is to get https://github.com/fhunleth/rpi_fb_capture/tree/dithering_plus_tests done. Except, now that I look at it again, I'd like to remove dithering from that branch and only focus on getting a unit test of each sampling method in. It could be that the code generates a rainbow picture programmatically and the unit test compares it with whatever it currently produces (Let's assume that the code is right today). Then get that merged. And then update the dithering branch so that it has unit tests.

Sorry for the long delay - I just got back from the final conference of this year for me. I have a little catch up to do for work, but I'm optimistic on being able to be more responsive. I can't work on it this week, but next week I can. Please don't let me slow you down if you have time this week. If you're on the elixir-lang slack, maybe we can pair sometime next week to get this done.

fhunleth commented 4 years ago

Looks like you're on Slack. :)

fhunleth commented 4 years ago

I finally got around to adding regression tests! Sorry for the delay.

Since I changed a lot of files, I went ahead and rebased your commits. See #6. I also added tests. Could you take a look? I believe that you have commit access to this repository, so please feel free to add commits should I have messed anything up.

I do think that something isn't quite right, though. Here's the test image:

image

Here's Floyd Steinberg:

image

Here's Sierra:

image

See the vertical stripe? That seems wrong, but I'm not sure.

If you want to try for yourself, the test files are in test/support. There's a script there for converting raw 1bpp pixel output to a png file.

fhunleth commented 4 years ago

Closing since I rebased this in #6.