This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def wavelet_analysis(sig): | |
""" decompose signal into wavelets | |
returns the frequence of the thesholded filtered signal | |
""" | |
widths = np.arange(1, 100,1) | |
cwtmatr = signal.cwt(sig, signal.ricker, widths) | |
N = sig.size | |
fsig = cwtmatr[98,:] | |
detect_pos = fsig>30 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
from skimage.morphology import watershed,disk | |
from skimage.filter import rank | |
from skimage import data | |
import numpy as np | |
image = data.camera() | |
gradient = rank.gradient(image, disk(2)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
label = np.asarray([[0,1],[2,3]]) | |
rgblabel = np.zeros([2,2,3]) | |
rgblabel[label==1,:]=[1,0,0] | |
rgblabel[label==2,:]=[0,1,0] | |
rgblabel[label==3,:]=[0,0,1] | |
plt.imshow(rgblabel,interpolation='nearest') | |
plt.show() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# opencv | |
import cv2.cv as cv | |
import cv2 | |
def build_filters(): | |
""" returns a list of kernels in several orientations | |
""" | |
filters = [] | |
ksize = 31 | |
for theta in np.arange(0, np.pi, np.pi / 32): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def convert_to_optical_densities(rgb,r0,g0,b0): | |
OD = rgb.astype(float) | |
OD[:,:,0] /= r0 | |
OD[:,:,1] /= g0 | |
OD[:,:,2] /= b0 | |
return -np.log(OD) | |
def color_deconvolution(rgb,r0,g0,b0,verbose=False): | |
stain_OD = np.asarray([[0.18,0.20,0.08],[0.01,0.13,0.0166],[0.10,0.21,0.29]]) #hematoxylin, eosyn, DAB |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#opencv | |
import cv2.cv as cv | |
import cv2 | |
import numpy as np | |
def build_filters(): | |
filters = [] | |
ksize = 31 | |
for theta in np.arange(0, np.pi, np.pi / 32): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
import matplotlib.cm as cm | |
def create_data(n): | |
data = np.reshape(range(n**2),(n,n)) | |
data = data[:,:,np.newaxis] | |
print '-'*40 | |
print data[:,:,0],data.shape | |
print '-'*40 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
n = 4 | |
data = np.reshape(range(4*4),(n,n)) | |
data = data[:,:,np.newaxis] | |
print data[:,:,0],data.shape | |
seq = [0,1,2,3] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from enthought.enable.api import ComponentEditor, BaseTool | |
from enthought.chaco.api import ArrayPlotData, Plot, jet, gray, PlotGraphicsContext | |
from enthought.traits.api import HasTraits, Instance, Enum, Range, Dict, Button, Int, Bool, Str, Property,Event, Array, DelegatesTo, on_trait_change,List, Tuple | |
from enthought.traits.ui.api import Item, Group, View, InstanceEditor | |
def draw_plot(filename, container,size=(800,600)): | |
"""Render a plot to file""" | |
container.outer_bounds = list(size) | |
container.do_layout(force=True) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from enthought.enable.api import ComponentEditor, BaseTool | |
from enthought.chaco.api import ArrayPlotData, Plot, jet, gray, PlotGraphicsContext | |
from enthought.traits.api import HasTraits, Instance, Enum, Range, Dict, Button, Int, Bool, Str, Property,Event, Array, DelegatesTo, on_trait_change,List, Tuple | |
from enthought.traits.ui.api import Item, Group, View, InstanceEditor | |
def draw_plot(filename, container,size=(800,600)): | |
"""Render a plot to file""" | |
container.outer_bounds = list(size) | |
container.do_layout(force=True) | |
gc = PlotGraphicsContext(size, dpi=150) |