Giter Club home page Giter Club logo

awb-lib's Introduction

AWB-Lib

Smoke Test

Implementation of a bunch of Automatic White-Balancing (AWBE algorithms), using JAX. Comparisons and experiments can be found in docs folder.

Implemented Algorithms | Example Results | Notes | License

Implemented Algorithms

  1. Gray World (GW), based on gray world assumption. See awblib.gw.
  2. Colour Histogram Stretching (CHS). See awblib.chs.
  3. Average Equalization and Threshold (AAET). See awblib.aaet.
  4. Histogram Matching (AWB-HM), based on histogram matching. See awblib.hm.
  5. Dynamic Histogram Matching (AWB-DHM), based on histogram matching and channel selection. See awblib.dhm.

AWB-DHM

T. Gollanapalli, V. R. Peddigari and P. S. Madineni, "Auto white balance using dynamic histogram matching for AMOLED panels," 2017 IEEE International Conference on Consumer Electronics-Asia (ICCE-Asia), Bengaluru, India, 2017, pp. 41-46, doi: 10.1109/ICCE-ASIA.2017.8307848.

Explanations about our implementation is here.

AWB-HM

Chengqiang Huang, Qi Zhang, Hui Wang, and Songlin Feng, "A Low Power and Low Complexity Automatic White Balance Algorithm for AMOLED Driving Using Histogram Matching," J. Display Technol. 11, 53-59 (2015)

Explanations about our implementation is here. This implementation largely reproduced the results.

CHS (Colour Histogram Stretching)

S. Wang, Y. Zhang, P. Deng and F. Zhou, "Fast automatic white balancing method by color histogram stretching," 2011 4th International Congress on Image and Signal Processing, Shanghai, China, 2011, pp. 979-983, doi: 10.1109/CISP.2011.6100338.

The implementation largely reproduced the results.

AWBAAET (Average Equalizatin and Threshold)

Shen-Chuan Tai, Tzu-Wen Liao, Yi-Ying Chang and Chih - Pei Yeh, "Automatic White Balance algorithm through the average equalization and threshold," 2012 8th International Conference on Information Science and Digital Content Technology (ICIDT2012), Jeju, Korea (South), 2012, pp. 571-576.

Example Results

See docs for more.

Report

Notes

Actually no paper has mentioned that if they are invariant to colour space or they depend on a specific colour space. As far as I know, most non-ML image processing algorithms require linear RGB; this processing is not done in this module yet.

The difference is performance (qualitatively, measured by overlapping area (OA) in colour histogram) is largely due to the discrete nature of the small image and thus the resultant histogram is often very discrete.

License

Apache-2.0

awb-lib's People

Contributors

joeyteng avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

awb-lib's Issues

DHM throws OverflowError with large images

DHM fails to handle images with resolution 5616x3744:

Failed handle \awb\awb_dataset\JPG\Canon1DsMkIII_0015.jpg with DHM: Traceback (most recent call last):
  File "\awb_ext.py", line 87, in awb_pic
    handled_pic = m(src_img.copy())
                  ^^^^^^^^^^^^^^^^^
  File "\awblib\dhm.py", line 130, in balance
    idx, k = jax.lax.cond(
             ^^^^^^^^^^^^^
  File "\venv\Lib\site-packages\awblib\dhm.py", line 107, in find_best_fit_channel_if_majority_below_half
    ch_ = channel_intensity.at[channel_idx].set(total_pixels * max_value)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "\venv\Lib\site-packages\jax\_src\numpy\array_methods.py", line 490, in set
    return scatter._scatter_update(self.array, self.index, values, lax.scatter,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "\venv\Lib\site-packages\jax\_src\ops\scatter.py", line 75, in _scatter_update
    y = jnp.asarray(y)
        ^^^^^^^^^^^^^^
  File "\venv\Lib\site-packages\jax\_src\numpy\lax_numpy.py", line 2233, in asarray
    return array(a, dtype=dtype, copy=bool(copy), order=order)  # type: ignore
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "\venv\Lib\site-packages\jax\_src\numpy\lax_numpy.py", line 2121, in array
    _ = dtypes.coerce_to_array(object, dtype)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
OverflowError: Python int 5382733824 too large to convert to int32
--------------------
For simplicity, JAX has removed its internal frames from the traceback of the following exception. Set JAX_TRACEBACK_FILTERING=off to include these.

Artefacts in CHS realization

You can see a lot of color artefacts in the AWB-Lib example of CHS and modCHS (https://github.com/JoeyTeng/AWB-Lib/blob/master/docs/assets/report.png). I mean some pixel have totally different color in comparison with as it should be. And there is a remark about it "The implementation largely reproduced the results", but in the corresponding article "Fast automatic white balancing method by color histogram stretching" there are no such artefacts. I think there is something wrong with the realization of CHS method in AWB-Lib

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.