-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShortcuts
More file actions
70 lines (50 loc) · 2.7 KB
/
Shortcuts
File metadata and controls
70 lines (50 loc) · 2.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
Luminance Function
def L(im):
imR = im[:,:,0]
imG = im[:,:,1]
imB = im[:,:,2]
L = 0.299*np.double(imR) + 0.587*np.double(imG) + 0.114*np.double(imB)
return L
Entropy
def loc_entropy(im,hood):
shape = np.shape(im)
s = int((hood-1)/2)
entr = np.zeros(shape)
for i in range(s,shape[0]-s):
for j in range(s,shape[1]-s):
h = sp.histogram(im[i-s:i+s+1,j-s:j+s+1],0,255,256)
S = 0
for freq in h:
p = freq/hood**2
S -= p*np.log2(p+ 10**-15)
entr[i,j] = S
return entr
skimage.filters.rank.entropy(image, footprint, ...)
- image has to be uint8, uint16
- footprint or hood has to be 0s or 1s
Prewitts' Filter
im = np.double(im)
imcanny = np.double(imcanny)
imchambole = np.double(imchambole)
prex = np.array([[-1, 0, 1], [-1, 0, 1], [-1, 0, 1]], dtype=np.double)
prey = np.array([[1, 1, 1], [0, 0, 0], [-1, -1, -1]], dtype=np.double)
impre = np.sqrt(ndimage.filters.convolve(im, prex)**2 + ndimage.filters.convolve(im, prey)**2)
imcannypre = np.sqrt(ndimage.filters.convolve(imcanny, prex)**2 + ndimage.filters.convolve(imcanny, prey)**2)
imchambolepre = np.sqrt(ndimage.filters.convolve(imchambole, prex)**2 + ndimage.filters.convolve(imchambole, prey)**2)
Erosion: ndimage.binary_erosion(imB, iterations=1, structure = np.ones((3,3)))
The value of the output pixel is the minimum value of all pixels in the neighborhood. In a binary image, a pixel is set to 0 if any of the neighboring pixels have the value 0.
Morphological erosion removes floating pixels and thin lines so that only substantive objects remain. Remaining lines appear thinner and shapes appear smaller.
Dilation: ndimage.binary_dilation(imM, iterations=1, structure = np.ones((3,3)))
The value of the output pixel is the maximum value of all pixels in the neighborhood. In a binary image, a pixel is set to 1 if any of the neighboring pixels have the value 1.
Morphological dilation makes objects more visible and fills in small holes in objects. Lines appear thicker, and filled shapes appear larger.
Opening: morphology.opening(imB), morphology.remove_small_objects(imBl)
Dilation of the erosion. Remove bright objects.
Closing: morphology.closing(imB), morphology.remove_small_holes(imM)
Erosion of the dilation. Remove small holes.
Binarization
Label: iml = measure.label(imM, connectivity = 2)
Distance Transform: imDT = ndimage.distance_transform_edt(imB)
Watershed Transform
wmax = feature.peak_local_max(imDT, footprint=np.ones((3, 3)), labels=imBl) # Index = False?
label_max = ndimage.label(wmax)
imWT = segmentation.watershed(imDT, markers = label_max[0], connectivity = 2, mask = imBl, watershed_line=True)