예제 #1
0
 def setUp(self):
     self.tempdir = tempfile.mkdtemp()
     self.cnn = PyCNN()
     self.exits_file_name = os.path.join(self.tempdir, 'exist.bmp')
     open(self.exits_file_name, 'w').close()
     self.not_supported_file = os.path.join(self.tempdir, 'exist.jp2')
     open(self.not_supported_file, 'w').close()
예제 #2
0
 def setUp(self):
     self.cnn = PyCNN()
     self.input = os.path.join(IMAGE_DIR, 'lenna.gif')
     self.output = os.path.join(
         tempfile.gettempdir(),
         'cnn_output.png',
     )
예제 #3
0
 def setUp(self):
     self.cnn = PyCNN()
     self.input1 = os.path.join(IMAGE_DIR, 'input1.bmp')
     self.input3 = os.path.join(IMAGE_DIR, 'input3.bmp')
     self.output = os.path.join(
         tempfile.gettempdir(),
         'cnn_output.png',
     )
예제 #4
0
 def setUp(self):
     self.tempdir = tempfile.mkdtemp()
     self.cnn = PyCNN()
     self.exits_file_name = os.path.join(self.tempdir, 'exist.bmp')
     open(self.exits_file_name, 'w').close()
     self.not_supported_file = os.path.join(self.tempdir, 'exist.jp2')
     open(self.not_supported_file, 'w').close()
예제 #5
0
 def setUp(self):
     self.cnn = PyCNN()
     self.input = os.path.join(IMAGE_DIR, 'lenna.gif')
     self.output = os.path.join(
         tempfile.gettempdir(),
         'cnn_output.png',
     )
예제 #6
0
 def setUp(self):
     self.cnn = PyCNN()
     self.input1 = os.path.join(IMAGE_DIR, 'input1.bmp')
     self.input3 = os.path.join(IMAGE_DIR, 'input3.bmp')
     self.output = os.path.join(
         tempfile.gettempdir(),
         'cnn_output.png',
     )
예제 #7
0
class TestProcessingLena(unittest.TestCase):

    def setUp(self):
        self.cnn = PyCNN()
        self.input = os.path.join(IMAGE_DIR, 'lenna.gif')
        self.output = os.path.join(
            tempfile.gettempdir(),
            'cnn_output.png',
        )

    def test_edgeDetection(self):
        self.cnn.edgeDetection(self.input, self.output)
        self.assertTrue(filecmp.cmp(
            self.output, os.path.join(IMAGE_DIR, 'lenna_edge.png'),
        ))

    def test_diagonalLineDetection(self):
        self.cnn.diagonalLineDetection(self.input, self.output)
        self.assertTrue(filecmp.cmp(
            self.output, os.path.join(IMAGE_DIR, 'lenna_diagonal.png'),
        ))
예제 #8
0
class TestProcessingLena(unittest.TestCase):
    def setUp(self):
        self.cnn = PyCNN()
        self.input = os.path.join(IMAGE_DIR, 'lenna.gif')
        self.output = os.path.join(
            tempfile.gettempdir(),
            'cnn_output.png',
        )

    def test_edgeDetection(self):
        self.cnn.edgeDetection(self.input, self.output)
        self.assertTrue(
            filecmp.cmp(
                self.output,
                os.path.join(IMAGE_DIR, 'lenna_edge.png'),
            ))

    def test_diagonalLineDetection(self):
        self.cnn.diagonalLineDetection(self.input, self.output)
        self.assertTrue(
            filecmp.cmp(
                self.output,
                os.path.join(IMAGE_DIR, 'lenna_diagonal.png'),
            ))
예제 #9
0
class TestMiscFunctions(unittest.TestCase):
    def setUp(self):
        self.tempdir = tempfile.mkdtemp()
        self.cnn = PyCNN()
        self.exits_file_name = os.path.join(self.tempdir, 'exist.bmp')
        open(self.exits_file_name, 'w').close()
        self.not_supported_file = os.path.join(self.tempdir, 'exist.jp2')
        open(self.not_supported_file, 'w').close()

    def tearDown(self):
        if os.path.exists(self.tempdir):
            shutil.rmtree(self.tempdir)

    def test_is_valid(self):
        self.cnn.validate(self.exits_file_name)
        with self.assertRaisesRegexp(IOError, 'does not exist'):
            self.cnn.validate('/not/exist/filename')
        with self.assertRaisesRegexp(IOError, 'is not a file'):
            self.cnn.validate(self.tempdir)
        with self.assertRaisesRegexp(Exception, 'is not supported'):
            self.cnn.validate(self.not_supported_file)
예제 #10
0
class TestMiscFunctions(unittest.TestCase):

    def setUp(self):
        self.tempdir = tempfile.mkdtemp()
        self.cnn = PyCNN()
        self.exits_file_name = os.path.join(self.tempdir, 'exist.bmp')
        open(self.exits_file_name, 'w').close()
        self.not_supported_file = os.path.join(self.tempdir, 'exist.jp2')
        open(self.not_supported_file, 'w').close()

    def tearDown(self):
        if os.path.exists(self.tempdir):
            shutil.rmtree(self.tempdir)

    def test_is_valid(self):
        self.cnn.validate(self.exits_file_name)
        with self.assertRaisesRegexp(IOError, 'does not exist'):
            self.cnn.validate('/not/exist/filename')
        with self.assertRaisesRegexp(IOError, 'is not a file'):
            self.cnn.validate(self.tempdir)
        with self.assertRaisesRegexp(Exception, 'is not supported'):
            self.cnn.validate(self.not_supported_file)
예제 #11
0
#!/usr/bin/python
# -*- coding: utf-8 -*-
from pycnn import PyCNN

# Initialize object
cnn = PyCNN()

# Perform respective image processing techniques on the given image

cnn.edgeDetection('images/input1.bmp', 'images/output1.png')
cnn.grayScaleEdgeDetection('images/input1.bmp', 'images/output2.png')
cnn.cornerDetection('images/input1.bmp', 'images/output3.png')
cnn.diagonalLineDetection('images/input1.bmp', 'images/output4.png')
cnn.inversion('images/input1.bmp', 'images/output5.png')
cnn.optimalEdgeDetection('images/input3.bmp', 'images/output6.png')
예제 #12
0
#!/usr/bin/python
# -*- coding: utf-8 -*-
from pycnn import PyCNN

# Initialize object
cnn = PyCNN()

# Perform respective image processing techniques on the given image

cnn.edgeDetection('images/lenna.gif', 'images/lenna_edge.png')
cnn.diagonalLineDetection('images/lenna.gif', 'images/lenna_diagonal.png')
예제 #13
0
class TestProcessing(unittest.TestCase):

    def setUp(self):
        self.cnn = PyCNN()
        self.input1 = os.path.join(IMAGE_DIR, 'input1.bmp')
        self.input3 = os.path.join(IMAGE_DIR, 'input3.bmp')
        self.output = os.path.join(
            tempfile.gettempdir(),
            'cnn_output.png',
        )

    def tearDown(self):
        if os.path.exists(self.output):
            os.remove(self.output)

    def test_edgeDetection(self):
        self.cnn.edgeDetection(self.input1, self.output)
        self.assertTrue(filecmp.cmp(
            self.output, os.path.join(IMAGE_DIR, 'output1.png'),
        ))

    def test_grayScaleEdgeDetection(self):
        self.cnn.grayScaleEdgeDetection(self.input1, self.output)
        self.assertTrue(filecmp.cmp(
            self.output, os.path.join(IMAGE_DIR, 'output2.png'),
        ))

    def test_cornerDetection(self):
        self.cnn.cornerDetection(self.input1, self.output)
        self.assertTrue(filecmp.cmp(
            self.output, os.path.join(IMAGE_DIR, 'output3.png'),
        ))

    def test_diagonalLineDetection(self):
        self.cnn.diagonalLineDetection(self.input1, self.output)
        self.assertTrue(filecmp.cmp(
            self.output, os.path.join(IMAGE_DIR, 'output4.png'),
        ))

    def test_inversion(self):
        self.cnn.inversion(self.input1, self.output)
        self.assertTrue(filecmp.cmp(
            self.output, os.path.join(IMAGE_DIR, 'output5.png'),
        ))

    def test_optimalEdgeDetection(self):
        self.cnn.optimalEdgeDetection(self.input3, self.output)
        self.assertTrue(filecmp.cmp(
            self.output, os.path.join(IMAGE_DIR, 'output6.png'),
        ))
예제 #14
0
class TestProcessing(unittest.TestCase):
    def setUp(self):
        self.cnn = PyCNN()
        self.input1 = os.path.join(IMAGE_DIR, 'input1.bmp')
        self.input3 = os.path.join(IMAGE_DIR, 'input3.bmp')
        self.output = os.path.join(
            tempfile.gettempdir(),
            'cnn_output.png',
        )

    def tearDown(self):
        if os.path.exists(self.output):
            os.remove(self.output)

    def test_edgeDetection(self):
        self.cnn.edgeDetection(self.input1, self.output)
        self.assertTrue(
            filecmp.cmp(
                self.output,
                os.path.join(IMAGE_DIR, 'output1.png'),
            ))

    def test_grayScaleEdgeDetection(self):
        self.cnn.grayScaleEdgeDetection(self.input1, self.output)
        self.assertTrue(
            filecmp.cmp(
                self.output,
                os.path.join(IMAGE_DIR, 'output2.png'),
            ))

    def test_cornerDetection(self):
        self.cnn.cornerDetection(self.input1, self.output)
        self.assertTrue(
            filecmp.cmp(
                self.output,
                os.path.join(IMAGE_DIR, 'output3.png'),
            ))

    def test_diagonalLineDetection(self):
        self.cnn.diagonalLineDetection(self.input1, self.output)
        self.assertTrue(
            filecmp.cmp(
                self.output,
                os.path.join(IMAGE_DIR, 'output4.png'),
            ))

    def test_inversion(self):
        self.cnn.inversion(self.input1, self.output)
        self.assertTrue(
            filecmp.cmp(
                self.output,
                os.path.join(IMAGE_DIR, 'output5.png'),
            ))

    def test_optimalEdgeDetection(self):
        self.cnn.optimalEdgeDetection(self.input3, self.output)
        self.assertTrue(
            filecmp.cmp(
                self.output,
                os.path.join(IMAGE_DIR, 'output6.png'),
            ))