Skip to content

Commit

Permalink
Merge pull request #65 from zohassadar/antialias_to_lanczos
Browse files Browse the repository at this point in the history
Replace deprecated antialias with lanczos
  • Loading branch information
alex-ong authored Dec 29, 2023
2 parents 488beeb + db09dd8 commit 3a9d882
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions nestris_ocr/assets/sample_inputs/easiercap/test_color1.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ def runFor(level, color, iterations=1):

start = time.time()
for i in range(iterations):
color = original_img.resize((1, 1), Image.ANTIALIAS).getpixel((0, 0))
color = original_img.resize((1, 1), Image.LANCZOS).getpixel((0, 0))

elapsed = time.time() - start
print("antialias", elapsed, elapsed / iterations)
print("antialias", color)

tmp = original_img.resize((1, 1), Image.ANTIALIAS).resize(
tmp = original_img.resize((1, 1), Image.LANCZOS).resize(
(big_size, big_size), Image.NEAREST
)
result_image.paste(tmp, (span * 3, result_y))
Expand Down Expand Up @@ -127,13 +127,13 @@ def runFor(level, color, iterations=1):

start = time.time()
for i in range(iterations):
color = cropped.resize((1, 1), Image.ANTIALIAS).getpixel((0, 0))
color = cropped.resize((1, 1), Image.LANCZOS).getpixel((0, 0))

elapsed = time.time() - start
print("cropped,antilias", elapsed, elapsed / iterations)
print("cropped,antilias", color)

tmp = cropped.resize((1, 1), Image.ANTIALIAS).resize(
tmp = cropped.resize((1, 1), Image.LANCZOS).resize(
(big_size, big_size), Image.NEAREST
)
result_image.paste(tmp, (span * 3, result_y + row_idx * span))
Expand Down
4 changes: 2 additions & 2 deletions nestris_ocr/assets/sample_inputs/easiercap/test_distances.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ def crop(source):


def getColorExisting(colImg):
return colImg.resize((1, 1), Image.ANTIALIAS).getpixel((0, 0))
return colImg.resize((1, 1), Image.LANCZOS).getpixel((0, 0))


def getColorCropBlurNearest(colImg):
return crop(colImg).filter(blur).resize((1, 1), Image.NEAREST).getpixel((0, 0))


def getColorCropAntialias(colImg):
return crop(colImg).resize((1, 1), Image.ANTIALIAS).getpixel((0, 0))
return crop(colImg).resize((1, 1), Image.LANCZOS).getpixel((0, 0))


def getColorCropBox(colImg):
Expand Down
2 changes: 1 addition & 1 deletion nestris_ocr/calibration/draw_calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,5 +281,5 @@ def draw_calibration(config):
for i in range(10):
uncached_capture().get_image(rgb=True)
highlight_calibration(img, config)
img = img.resize((512, 448), Image.ANTIALIAS)
img = img.resize((512, 448), Image.LANCZOS)
return img
4 changes: 2 additions & 2 deletions nestris_ocr/ocr_algo/digit.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def setupColour(prefix, outputDict, digitList):
img = img.convert("L")
if IMAGE_MULT != 1:
img = img.resize(
(SCALED_IMAGE_SIZE, SCALED_IMAGE_SIZE), PIL.Image.ANTIALIAS
(SCALED_IMAGE_SIZE, SCALED_IMAGE_SIZE), PIL.Image.LANCZOS
)

img = img.getdata()
Expand Down Expand Up @@ -89,7 +89,7 @@ def contrastImg(img):

def convertImg(img, count, show):
img = contrastImg(img)
img = img.resize(finalImageSize(count), PIL.Image.ANTIALIAS)
img = img.resize(finalImageSize(count), PIL.Image.LANCZOS)

if show:
img.show()
Expand Down

0 comments on commit 3a9d882

Please sign in to comment.