예제 #1
0
def test_dog():
    im = mh.demos.load('lena')
    im = im.mean(2)
    edges = mh.dog(im)
    assert edges.shape == im.shape
    assert edges.any()
    edges1 = mh.dog(im, sigma1=1.)
    assert np.any(edges != edges1)
def test_dog():
    im = mh.demos.load('lena')
    im = im.mean(2)
    edges = mh.dog(im)
    assert edges.shape == im.shape
    assert edges.any()
    edges1 = mh.dog(im, sigma1=1.)
    assert np.any(edges != edges1)
예제 #3
0
 def extractFeatures(self,img,feature_indices=None):      
     if self.compute_dog:
         img = mh.dog(img)
     features= mh.features.haralick(img).mean(0)
     if feature_indices == None:
         feature_indices = self.selected_features
     retval = [features[i] for i in feature_indices]
     return retval
예제 #4
0
 def extractFeaturesWithHaralick(self,img):
     kpts = self.keypoints(img)
     features = np.asarray(self.haralickFromKeypoint(img,kpts[0])).reshape(-1,5)
     if self.compute_dog:
         img = mh.dog(img)
     for kpt_index in range(1,len(kpts)):
         new_features = np.asarray(self.haralickFromKeypoint(img,kpts[kpt_index])).reshape(-1,5)
         features = np.append(features,new_features,axis=0)
     return features
예제 #5
0

f = mh.imread('/home/zo/PycharmProjects/cal-app/person/zj/learn/python-ml/vision4op/image/IMG_1962.JPG') #treegroup_1.JPG')
    #'/home/zo/Downloads/mahotas-master/mahotas/demos/data/nuclear.png')
#mh.demos.nuclear_image()

f = f[:213,380:650,1]

f[50,:] = 0

# ashe f[:213,10:271,0]
#line:f[326:415,172:250,2]
print f.shape, f.mean() ,f.std()
pylab.imshow(f)
pylab.show()

#pylab.hist(f)
#pylab.show()

edges = mh.dog(f) # , just_filter=True) #sobel
pylab.imshow(edges)
pylab.show()
print edges.shape, edges.mean() ,edges.std()

#edges = mh.gaussian_filter(edges,1)
thred = edges.mean()
edges = (edges > thred )
pylab.imshow(edges)
pylab.show()

예제 #6
0
import mahotas
import numpy as np
from pylab import imshow, gray, show, subplot
from os import path

lena_image = path.join(path.dirname(path.abspath(__file__)), 'data',
                       'lena.jpg')

photo = mahotas.imread(lena_image, as_grey=True)
photo = photo.astype(np.uint8)

gray()
subplot(131)
imshow(photo)

edge_sobel = mahotas.sobel(photo)
subplot(132)
imshow(edge_sobel)

edge_dog = mahotas.dog(photo)
subplot(133)
imshow(edge_dog)
show()
예제 #7
0
import mahotas
import numpy as np
from pylab import imshow, gray, show, subplot
from os import path

lena_image = path.join(
                    path.dirname(path.abspath(__file__)),
                    'data',
                    'lena.jpg')

photo = mahotas.imread(lena_image, as_grey=True)
photo = photo.astype(np.uint8)

gray()
subplot(131)
imshow(photo)

edge_sobel = mahotas.sobel(photo)
subplot(132)
imshow(edge_sobel)

edge_dog = mahotas.dog(photo)
subplot(133)
imshow(edge_dog)
show()