# Path: kraken/lib/lineest.py
# def scale_to_h(img, target_height, order=1, dtype=np.dtype('f'), cval=0):
#     def __init__(self, target_height=48, params=(4, 1.0, 0.3)):
#     def setHeight(self, target_height):
#     def measure(self, line):
#     def dewarp(self, img, cval=0, dtype=np.dtype('f')):
#     def normalize(self, img, order=1, dtype=np.dtype('f'), cval=0):
# def dewarp(normalizer: CenterNormalizer, im: Image.Image) -> Image.Image:
# class CenterNormalizer(object):


import unittest
from PIL import Image
from pathlib import Path
from pytest import raises
from kraken.lib import lineest

    def test_dewarp_bw(self):
        """
        Test dewarping of a single line in B/W
        """
        with Image.open(resources / '000236.png') as im:
            o = lineest.dewarp(self.lnorm, im.convert('1'))
            self.assertEqual(self.lnorm.target_height, o.size[1])

    def test_dewarp_gray(self):
        """
        Test dewarping of a single line in grayscale
        """
        with Image.open(resources /'000236.png') as im:
            o = lineest.dewarp(self.lnorm, im.convert('L'))
            self.assertEqual(self.lnorm.target_height, o.size[1])

    def test_dewarp_fail_color(self):
        """
        Test dewarping of a color line fails
        """
        with raises(ValueError):
            with Image.open(resources /'000236.png') as im:
                lineest.dewarp(self.lnorm, im.convert('RGB'))

    def test_dewarp_bw_undewarpable(self):
        """
        Test dewarping of an undewarpable line.
        """
        with Image.open(resources /'ONB_ibn_19110701_010.tif_line_1548924556947_449.png') as im:

# Path: kraken/lib/lineest.py
# def scale_to_h(img, target_height, order=1, dtype=np.dtype('f'), cval=0):
#     def __init__(self, target_height=48, params=(4, 1.0, 0.3)):
#     def setHeight(self, target_height):
#     def measure(self, line):
#     def dewarp(self, img, cval=0, dtype=np.dtype('f')):
#     def normalize(self, img, order=1, dtype=np.dtype('f'), cval=0):
# def dewarp(normalizer: CenterNormalizer, im: Image.Image) -> Image.Image:
# class CenterNormalizer(object):


# Path: tests/test_lineest.py
import unittest
from PIL import Image
from pathlib import Path
from pytest import raises
from kraken.lib import lineest


    def test_dewarp_bw(self):
        """
        Test dewarping of a single line in B/W
        """
        with Image.open(resources / '000236.png') as im:
            o = lineest.dewarp(self.lnorm, im.convert('1'))
            self.assertEqual(self.lnorm.target_height, o.size[1])

    def test_dewarp_gray(self):
        """
        Test dewarping of a single line in grayscale
        """
        with Image.open(resources /'000236.png') as im:
            o = lineest.dewarp(self.lnorm, im.convert('L'))
            self.assertEqual(self.lnorm.target_height, o.size[1])

    def test_dewarp_fail_color(self):
        """
        Test dewarping of a color line fails
        """
        with raises(ValueError):
            with Image.open(resources /'000236.png') as im:
                lineest.dewarp(self.lnorm, im.convert('RGB'))

    def test_dewarp_bw_undewarpable(self):
        """
        Test dewarping of an undewarpable line.
        """
        with Image.open(resources /'ONB_ibn_19110701_010.tif_line_1548924556947_449.png') as im:

            o = lineest.dewarp(self.lnorm, im)