Mercurial > hg > segmentation
comparison novelty.py @ 1:c11ea9e0357f
adding funcs
author | mitian |
---|---|
date | Thu, 02 Apr 2015 22:16:38 +0100 |
parents | 26838b1f560f |
children | 294f66d285af |
comparison
equal
deleted
inserted
replaced
0:26838b1f560f | 1:c11ea9e0357f |
---|---|
8 """ | 8 """ |
9 | 9 |
10 import sys, os | 10 import sys, os |
11 import numpy as np | 11 import numpy as np |
12 from scipy.signal import correlate2d, convolve2d | 12 from scipy.signal import correlate2d, convolve2d |
13 import matplotlib.pyplot as plt | |
13 | 14 |
14 # from utils.PeakPickerUtil import PeakPicker | 15 # from utils.PeakPickerUtil import PeakPicker |
15 | 16 |
16 def getNoveltyCurve(ssm, kernel_size, normalise=False): | 17 def getNoveltyCurve(ssm, kernel_size, normalise=False): |
17 '''Return novelty score from ssm.''' | 18 '''Return novelty score from ssm.''' |
58 else: | 59 else: |
59 kernel[i-1,j-1] = gauss | 60 kernel[i-1,j-1] = gauss |
60 | 61 |
61 return kernel | 62 return kernel |
62 | 63 |
63 def getNoveltyPeaks(ssm, kernel_size, peak_picker, normalise=False): | 64 def process(ssm, kernel_size, peak_picker, normalise=False, plot=False): |
64 '''Detect segment boundaries in the ssm.''' | 65 '''Detect segment boundaries in the ssm.''' |
65 novelty = getNoveltyCurve(ssm, kernel_size, normalise=False) | 66 novelty = getNoveltyCurve(ssm, kernel_size, normalise=False) |
66 smoothed_novelty, novelty_peaks = peak_picker.process(novelty) | 67 smoothed_novelty, novelty_peaks = peak_picker.process(novelty) |
67 | 68 |
69 if plot: | |
70 plot_detection(smoothed_novelty, novelty_peaks) | |
68 return novelty, smoothed_novelty, novelty_peaks | 71 return novelty, smoothed_novelty, novelty_peaks |
72 | |
73 def plot_detection(smoothed_novelty, novelty_peaks): | |
74 pass |