예제 #1
0
    def test_mouse_point(self):
        # img test
        self.assertRaises(TypeError, lambda: bo.mouse_point(self.fake_img))
        # name test
        self.assertRaises(TypeError, lambda: bo.mouse_point(self.img_3c, self.fake_name))
        # mode test
        self.assertRaises(TypeError, lambda: bo.mouse_point(self.img_3c, mode=self.fake_mode))
        self.assertRaises(ValueError, lambda: bo.mouse_point(self.img_3c, mode=self.false_mode))
        # TODO: How to test arguments that need user interaction?
        
#if __name__ == "__main__":
    #unittest.main()
예제 #2
0
    def test_mouse_point(self):
        # img test
        self.assertRaises(TypeError, lambda: bo.mouse_point(self.fake_img))
        # name test
        self.assertRaises(TypeError,
                          lambda: bo.mouse_point(self.img_3c, self.fake_name))
        # mode test
        self.assertRaises(
            TypeError,
            lambda: bo.mouse_point(self.img_3c, mode=self.fake_mode))
        self.assertRaises(
            ValueError,
            lambda: bo.mouse_point(self.img_3c, mode=self.false_mode))
        # TODO: How to test arguments that need user interaction?


#if __name__ == "__main__":
#unittest.main()
예제 #3
0
The following method uses one seed point, defined by the user. The region grows by comparing with its neighbourhood. The chosen criteria is in this case a difference between outside pixel's intensity value and the region's mean.
The pixel with minimum intensity in the region neighbouhood is chosen to be included. The growing stops as soon as the difference is larger than a threshold. 

In this implementation, a 4-connectivity has been chosen. The 8-connectivity should be included soon. 
Due to the method itself, only grayscale images may be processed for now. So color images should be converted first. 

'''

import cv
import tippy.segmentations as se
import tippy.basic_operations as bo
import tippy.display_operations as do


user_input = 0

img_name = "tippy/data/gnu.jpg"
threshold = 20
connectivity = 8
img = cv.LoadImage(img_name, cv.CV_LOAD_IMAGE_GRAYSCALE)

if user_input:
    seed = bo.mouse_point(img, mode="S") # waits for user click to get seed
else:
    seed = (70, 106)

out_img = se.simple_region_growing(img, seed, threshold, connectivity)

do.display_single_image(out_img, "Region Growing result")
예제 #4
0
Region growing is massively used in medical imaging, and object detection. Here is an example of application in automatic Mine Hunting, which I worked with last year at TNO. 

The following method uses one seed point, defined by the user. The region grows by comparing with its neighbourhood. The chosen criteria is in this case a difference between outside pixel's intensity value and the region's mean.
The pixel with minimum intensity in the region neighbouhood is chosen to be included. The growing stops as soon as the difference is larger than a threshold. 

In this implementation, a 4-connectivity has been chosen. The 8-connectivity should be included soon. 
Due to the method itself, only grayscale images may be processed for now. So color images should be converted first. 

'''

import cv
import tippy.segmentations as se
import tippy.basic_operations as bo
import tippy.display_operations as do

user_input = 0

img_name = "tippy/data/gnu.jpg"
threshold = 20
connectivity = 8
img = cv.LoadImage(img_name, cv.CV_LOAD_IMAGE_GRAYSCALE)

if user_input:
    seed = bo.mouse_point(img, mode="S")  # waits for user click to get seed
else:
    seed = (70, 106)

out_img = se.simple_region_growing(img, seed, threshold, connectivity)

do.display_single_image(out_img, "Region Growing result")