def test_hprewitt_vertical():
    """Horizontal prewitt on a vertical edge should be zero"""
    i, j = np.mgrid[-5:6, -5:6]
    image = (j >= 0).astype(float)
    result = F.hprewitt(image)
    eps = .000001
    assert (np.all(np.abs(result) < eps))
def test_hprewitt_mask():
    """Horizontal prewitt on a masked array should be zero"""
    np.random.seed(0)
    result = F.hprewitt(np.random.uniform(size=(10, 10)),
                        np.zeros((10, 10), bool))
    eps = .000001
    assert (np.all(np.abs(result) < eps))
Beispiel #3
0
def test_hprewitt_mask():
    """Horizontal prewitt on a masked array should be zero"""
    np.random.seed(0)
    result = F.hprewitt(np.random.uniform(size=(10, 10)),
                        np.zeros((10, 10), bool))
    eps = .000001
    assert (np.all(np.abs(result) < eps))
Beispiel #4
0
def test_hprewitt_vertical():
    """Horizontal prewitt on a vertical edge should be zero"""
    i, j = np.mgrid[-5:6, -5:6]
    image = (j >= 0).astype(float)
    result = F.hprewitt(image)
    eps = .000001
    assert (np.all(np.abs(result) < eps))
Beispiel #5
0
def post_process(img):
    """
    Post-processes the results using skimage filters
    """
    filt_1 = ski_filter.hprewitt(img)
    filt_2 = exposure.equalize_hist(filt_1)

    return filt_2
Beispiel #6
0
def post_process(img):
    """
    Post-processes the results using skimage filters
    """
    filt_1 = ski_filter.hprewitt(img)
    filt_2 = exposure.equalize_hist(filt_1)

    return filt_2
Beispiel #7
0
def test_hprewitt_horizontal():
    """Horizontal prewitt on an edge should be a horizontal line."""
    i, j = np.mgrid[-5:6, -5:6]
    image = (i >= 0).astype(float)
    result = F.hprewitt(image)
    # Fudge the eroded points
    i[np.abs(j) == 5] = 10000
    assert (np.all(result[i == 0] == 1))
    assert_allclose(result[np.abs(i) > 1], 0, atol=1e-10)
def test_hprewitt_horizontal():
    """Horizontal prewitt on an edge should be a horizontal line"""
    i, j = np.mgrid[-5:6, -5:6]
    image = (i >= 0).astype(float)
    result = F.hprewitt(image)
    # Fudge the eroded points
    i[np.abs(j) == 5] = 10000
    eps = .000001
    assert (np.all(result[i == 0] == 1))
    assert (np.all(np.abs(result[np.abs(i) > 1]) < eps))
Beispiel #9
0
    def classify(self,sample,fingerName,jointName):
        max=sample.max()
        sample=sample/max*255
        sample=sample.astype('uint8')
                 
        cropSamp=sample[self.windowSize[0]:self.windowSize[1],self.windowSize[2]:self.windowSize[3]]
        cropSamp=tv_denoise(cropSamp,weight=0.2)
        
        if self.verbose:
            plt.imshow(cropSamp,cmap=plt.cm.gray)
            plt.show()
        
        cropSamp=filter.hprewitt(cropSamp)

        if self.verbose:
            plt.imshow(cropSamp,cmap=plt.cm.gray)
            plt.show()
        
        #idx=cropSamp<0.08
        #cropSamp[idx]=0    
        
        if self.verbose:
            plt.imshow(cropSamp,cmap=plt.cm.gray)
            plt.show()
        
        scores = []
        for classImage in self.classImages:      
            classImage=tv_denoise(classImage,weight=0.2)
            classImage=filter.hprewitt(classImage)
            
            #idx=classImage<0.08
            #classImage[idx]=0 
            
            if False and self.verbose:
                plt.imshow(classImage,cmap=plt.cm.gray)
                plt.show()
            #do template matching
            score = match_template(classImage, cropSamp,1)
            scores.append(np.max(score))
        
        classification = self.classLabels[np.argmax(scores)]
        
        return classification
Beispiel #10
0
def test_hprewitt_horizontal():
    """Horizontal prewitt on an edge should be a horizontal line"""
    i, j = np.mgrid[-5:6, -5:6]
    image = (i >= 0).astype(float)
    result = F.hprewitt(image)
    # Fudge the eroded points
    i[np.abs(j) == 5] = 10000
    eps = .000001
    assert (np.all(result[i == 0] == 1))
    assert (np.all(np.abs(result[np.abs(i) > 1]) < eps))
Beispiel #11
0
def test_hprewitt_mask():
    """Horizontal prewitt on a masked array should be zero."""
    np.random.seed(0)
    result = F.hprewitt(np.random.uniform(size=(10, 10)),
                        np.zeros((10, 10), bool))
    assert_allclose(result, 0)
Beispiel #12
0
def test_hprewitt_zeros():
    """Horizontal prewitt on an array of all zeros."""
    result = F.hprewitt(np.zeros((10, 10)), np.ones((10, 10), bool))
    assert_allclose(result, 0)
def test_hprewitt_zeros():
    """Horizontal prewitt on an array of all zeros"""
    result = F.hprewitt(np.zeros((10, 10)), np.ones((10, 10), bool))
    assert (np.all(result == 0))
Beispiel #14
0
 def vedges(self):
     """x=vedges(): returns a parameterization of the number of vertical edges versus total edges in an RGB image"""
     hprew=filter.hprewitt(self.gray)
     vprew=filter.vprewitt(self.gray)
     vfrac=vprew.sum()/(vprew.sum()+hprew.sum())
     return vfrac
Beispiel #15
0
def test_hprewitt_zeros():
    """Horizontal prewitt on an array of all zeros"""
    result = F.hprewitt(np.zeros((10, 10)), np.ones((10, 10), bool))
    assert (np.all(result == 0))
Beispiel #16
0
 def test_00_00_zeros(self):
     """Horizontal sobel on an array of all zeros"""
     result = F.hprewitt(np.zeros((10, 10)), np.ones((10, 10), bool))
     assert (np.all(result == 0))
Beispiel #17
0
def test_hprewitt_vertical():
    """Horizontal prewitt on a vertical edge should be zero."""
    i, j = np.mgrid[-5:6, -5:6]
    image = (j >= 0).astype(float)
    result = F.hprewitt(image)
    assert_allclose(result, 0, atol=1e-10)
Beispiel #18
0
 def test_00_00_zeros(self):
     """Horizontal sobel on an array of all zeros"""
     result = F.hprewitt(np.zeros((10, 10)), np.ones((10, 10), bool))
     assert (np.all(result == 0))