mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-04 16:57:32 +08:00
Added Burkes dithering algorithm. (#1916)
* Added Burkes dithering algorithm * Added unit tests for burkes algorithm * Fix burkes algorithm * Added some additional information * Fixed CI tests * Update digital_image_processing/dithering/burkes.py Co-Authored-By: Christian Clauss <cclauss@me.com> * Update digital_image_processing/dithering/burkes.py Co-Authored-By: Christian Clauss <cclauss@me.com> * Update digital_image_processing/dithering/burkes.py Co-Authored-By: Christian Clauss <cclauss@me.com> * Propogate the += and add a doctest * Fix doctest * @staticmethod --> @ classmethod to ease testing * def test_burkes(file_path): * Fix for mypy checks * Fix variable order in get_greyscale * Fix get_greyscale method * Fix get_greyscale method * 3.753 Co-authored-by: Christian Clauss <cclauss@me.com>
This commit is contained in:
@ -10,6 +10,7 @@ import digital_image_processing.filters.convolve as conv
|
||||
import digital_image_processing.change_contrast as cc
|
||||
import digital_image_processing.convert_to_negative as cn
|
||||
import digital_image_processing.sepia as sp
|
||||
import digital_image_processing.dithering.burkes as bs
|
||||
from cv2 import imread, cvtColor, COLOR_BGR2GRAY
|
||||
from numpy import array, uint8
|
||||
from PIL import Image
|
||||
@ -17,6 +18,7 @@ from PIL import Image
|
||||
img = imread(r"digital_image_processing/image_data/lena_small.jpg")
|
||||
gray = cvtColor(img, COLOR_BGR2GRAY)
|
||||
|
||||
|
||||
# Test: convert_to_negative()
|
||||
def test_convert_to_negative():
|
||||
negative_img = cn.convert_to_negative(img)
|
||||
@ -74,3 +76,9 @@ def test_sobel_filter():
|
||||
def test_sepia():
|
||||
sepia = sp.make_sepia(img, 20)
|
||||
assert sepia.all()
|
||||
|
||||
|
||||
def test_burkes(file_path: str="digital_image_processing/image_data/lena_small.jpg"):
|
||||
burkes = bs.Burkes(imread(file_path, 1), 120)
|
||||
burkes.process()
|
||||
assert burkes.output_img.any()
|
||||
|
Reference in New Issue
Block a user