JuliaImages / DitherPunk.jl

Dithering algorithms in Julia.
MIT License
60 stars 3 forks source link

Add direct binary search (DBS) #25

Open adrhill opened 3 years ago

adrhill commented 3 years ago

As described in [1] and Chapter 7 of Modern Digital Halftoning by Lau & Are.

[1] Analoui, M.; Allebach, J.P. (February 1992). "Model-based Halftoning by Direct Binary Search". Proceedings of the 1992 SPIE/IS&T Symposium on Electronic Imaging Science and Technology. 1666: 9–14.

Jay-sanjay commented 1 year ago

what's the issue sir

ashwani-rathee commented 1 year ago

More reference: http://caca.zoy.org/study/part4.html

adrhill commented 1 year ago

Hi @Jay-sanjay,

together with issues #24 and #26, this issue tracks a dithering algorithm that would be nice to have in DitherPunk.jl.

For a list of already implemented methods, refer to the list in the README and the gallery.

If you are looking to contribute the direct binary search algorithm to DitherPunk.jl, you only need to create an algorithm struct that is a subtype of AbstractDither, a function binarydither! and optionally a function colordither. The source code of ClosestColor is probably the best entry point into the code.

I would be more than glad to assist you if you are interested in contributing! :)

Jay-sanjay commented 1 year ago

@adrhill Sir, while implementing the binarydither! ( ) function should it return 1 if pixel value in the input image is greater than the threshold and 0 in the else case . What must be done could you please assist me further !

adrhill commented 1 year ago

Hi @Jay-sanjay, functions binarydither! are supposed to modify the argument output in-place. In-place modifying functions in Julia are usually indicated by an exclamation point ! in their name by convention.

Writing a 1 into out will turn that pixel white. Writing a 0 into out will turn that pixel black.

I hope the following screenshot helps to illustrate this:

image
Jay-sanjay commented 1 year ago

Yes , Sir should the algorithm be something like : binarydither! function should iterate over each pixel in the input image and assign the output pixel to the closest color in the color palette and the distances between the two colors measured via theirdiif. in grayscale values if it is greater than thresold , return 1 else return 0.

is it enough