Ejemplo n.º 1
0
 def test_thresh_val(self):
     """ Assert that the threshold value is between 0 and 255 """
     img = Imagemanip(url)
     img.single_color()
     img.convert_binary(scale=3, thresh_val=200)
     self.assertGreater(img.thresh_val, 0)  # thresh_val > 0
     self.assertLess(img.thresh_val, 255)  # thresh_val < 255
Ejemplo n.º 2
0
 def test_convert_binary(self):
     """ assert that the image array is binary with 0 (black) and 255 (white) """
     img = Imagemanip(url)
     img.single_color()
     img.convert_binary(scale=3, thresh_val=200)
     for i in range(len(img.image_array)):
         for j in range(len(img.image_array[0])):
             self.assertIn(img.image_array[i][j], (1, 255))  # = 0 or 255
Ejemplo n.º 3
0
import sys
sys.path.append("..")
from ImageManipulation.Imgmanip import Imagemanip
from FourierApproximation.Class_fourierApproximation import FourierApprox
import unittest

url = 'https://www.seekpng.com/png/detail/116-1164659_line-drawing-bunny-rabbit-at-getdrawings-bunny-drawing.png'
Img = Imagemanip(url)
Img.single_color()
Img.convert_binary(scale=3, thresh_val=200)
Img.black_and_white()
Img.distance_matrix()
Img.contours_search()
Img.get_splines()


class TestFourierApprox(unittest.TestCase):
    def test_FourierApprox_is_instance_of_FourierApprox(self):
        """ Assert that the Fourier object is created """
        xFT = FourierApprox(Img.x_spl, (0, Img.length_pixels), num_circles=50)
        self.assertIsInstance(xFT, FourierApprox)

    def test_origin_offset_is_float(self):
        """ Assert that the attribute origin_offset of the FourierApprox object is a float """
        xFT = FourierApprox(Img.x_spl, (0, Img.length_pixels), num_circles=50)
        self.assertIsInstance(xFT.origin_offset, float)

    def test_circles_approximation_offset_is_float(self):
        """ Assert that the attribute circles_approximation_offset of the FourierApprox object is a float """
        xFT = FourierApprox(Img.x_spl, (0, Img.length_pixels), num_circles=50)
        self.assertIsInstance(xFT.circles_approximation_offset, float)
    def test_img_object(self):
        """ Assert that the image object is created """

        img = Imagemanip(url)
        self.assertIsInstance(img, Imagemanip)