-
Notifications
You must be signed in to change notification settings - Fork 17
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
Initial version of Floyd Steinberg Dithering #25
base: master
Are you sure you want to change the base?
Conversation
We first extract some information from the image - width, height etc., convert to luma and compute gradients. Then, for each pixel (x,y), we compute rho = xcos(theta) + ysin(theta). After a few more transformations and finding the bins with highest values, we generate the resulting image.
Preliminary Hough transform implementation
It is used to improve contrast in images and works by performing enhancement on small 'contextual' regions or neighborhood of each pixel in the given image.
Adaptive Histogram Equalization
Laplacian filter
Fix the horizontal kernel of Sobel filter.
* Mean filter version 1
@lehins Sir, I have a few doubts regarding the algorithm and so I'm starting a PR at an early stage so as I can discuss a thing or two with you. |
@lehins Firstly, I'm a bit confused about finding the R,G and B values in the double range (0, 1). Please forgive me if this is something very silly. I had a bit less time so started a PR early, am still reading and working upon this. Hope you don't mind :-) |
@lehins The psudocode for the algo is available at https://en.wikipedia.org/wiki/Floyd%E2%80%93Steinberg_dithering |
dithering | ||
:: forall arr e cs . ( MArray arr RGB Double, IP.Array arr RGB Double, IP.Array arr RGB Double) | ||
=> Image arr RGB Double | ||
-> Int -- ^ width of output image |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You always ask for those arguments width and height, why is that? It's not C, you can call dims
and get the dimensions of the source and result image
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lehins Oh yes, very sorry for repeating the mistake. Wont happen again.
@khilanravani Why are confused that RGB values are in [0,1] range? What should they be? Also what does this operation on RGB be does? I couldn't see on the wiki reference you added:
What are you trying to achieve here? |
Oh and, I got no problem with an early PR and will happily discuss the algorithm and implementation with you |
@lehins Sir, I need to find the nearest palette color (of R,G and B) and then need to find the error from the original pixel color to those (0.1, 0.5 & 0.85 are just fictional values representing the palette colors R,G and B). Plz forgive me if I'm overlooking something very silly. |
I see what's going on. Looks like you'd need to come up with an algorithm for coming up with a palette for a a color image before you can do dithering. Maybe you should first try to get Dithering to work for Luma images going from |
@lehins Okay sir, I'll try it out. Thank u! Ping u later. |
@lehins Here is the implementation for luma images sir. I hope that I got it right. For now, I've hard-coded the color values but can update them soon if you feel that this is the correct way. For your reference, a sample output : |
An outline implementation of Floyd Steinberg Dithering algorithm (The errors calculated are not exactly correct and the values currently used are testing ones). Please note that this is an initial version and so the output generated is only as per the testing values.