コード例 #1
0
    def test_identity_filter_grey(self):
        '''
	Tests whether the convolution identity returns the original image
	'''
        identity = np.zeros((3, 3))
        identity[1, 1] = 1
        img_dup = hybrid.convolve_2d(self.small_img_grey, identity)
        self.assertTrue(np.allclose(img_dup, self.small_img_grey, atol=1e-08), \
         msg="Failed to return original image under identity convolution")
コード例 #2
0
ファイル: test.py プロジェクト: EdwardFengsc/Computer-Vision
    def test_mean_filter_grey(self):
	'''
	Tests convolution of greyscale image using mean filter
	'''
	mean = np.ones((3,3))
	student = hybrid.convolve_2d(self.small_img_grey, mean)
	solution = cv2.filter2D(self.small_img_grey, -1, mean, borderType=cv2.BORDER_CONSTANT)

	self.assertTrue(np.allclose(student, solution, atol=1e-08), \
		msg="Incorrect result convolving greyscale image using mean filter")
コード例 #3
0
ファイル: test.py プロジェクト: EdwardFengsc/Computer-Vision
    def test_mean_filter_RGB(self):
	'''
	Tests convolution of RGB image using a rectangular filter
	'''
	mean = np.ones((3,3))
	student = hybrid.convolve_2d(self.img_rgb, mean)
	solution = cv2.filter2D(self.img_rgb, -1, mean, borderType=cv2.BORDER_CONSTANT)

	self.assertTrue(np.allclose(student, solution, atol=1e-08), \
		msg="Incorrect result convolving RGB image using mean filter")
コード例 #4
0
ファイル: test.py プロジェクト: jc2528/compvision
    def test_rand_rect_filter_RGB(self):
	'''
	Tests convolution of RGB image using a random rectangular filter
	'''
	rand_filt = np.random.rand(5,7)
	rand_filt_trans = np.fliplr(np.flipud(rand_filt))
	student = hybrid.convolve_2d(self.img_rgb, rand_filt)
	solution = cv2.filter2D(self.img_rgb, -1, rand_filt_trans, borderType=cv2.BORDER_CONSTANT)
	self.assertTrue(np.allclose(student, solution, atol=1e-08), \
		msg="Incorrect result convolving RGB image using random rectangular filter")
コード例 #5
0
ファイル: test.py プロジェクト: EdwardFengsc/Computer-Vision
    def test_big_filter_grey(self):
	'''
	Tests convolution of greyscale image using a filter bigger than image
	'''
	filter_height = self.small_height % 2 + self.small_height + 1
	filter_width = self.small_width % 2 + self.small_width + 1
	rand_filt = np.random.rand(filter_height, filter_width)
	rand_filt_trans = np.fliplr(np.flipud(rand_filt))
	student = hybrid.convolve_2d(self.small_img_grey, rand_filt)
	solution = cv2.filter2D(self.small_img_grey, -1, rand_filt_trans, borderType=cv2.BORDER_CONSTANT)

	self.assertTrue(np.allclose(student, solution, atol=1e-08), \
		msg="Incorrect result convolving greyscale image using filter bigger than image")