from skimage import img_as_float, img_as_ubyte from skimage.color import rgb2hed from sklearn.cross_validation import train_test_split from sklearn.decomposition import RandomizedPCA, SparsePCA, IncrementalPCA from sklearn.grid_search import GridSearchCV from sklearn.svm import SVC from sklearn.metrics import accuracy_score from sklearn.preprocessing import normalize from hed_bilateral import HedBilateralFilter from segment_hist import SegmentStage from cellcounting import common as com from cellcounting.features.hog import HOGFeature from cellcounting.features.lbp import LBP # Create samples and its label preprocessor = HedBilateralFilter() filter_kernel = (7, 7) preprocessor.set_param("bilateral_kernel", filter_kernel) preprocessor.set_param("sigma_color", 9) segment = SegmentStage(5) hog = HOGFeature() lbp = LBP(2, 16, "var") labels = [] def load_list_files(filename): """ load all data form the file of list data """ files = [] data = [] hist_data = []
from hed_bilateral import HedBilateralFilter from segment_hist import SegmentStage from cellcounting import common as com try: filename = sys.argv[1] except: filename = "allidb2.txt" files = [] with open(filename, "r") as f: files = [line.strip() for line in f.readlines()] # Create samples and its label preprocessor = HedBilateralFilter() filter_kernel = (7, 7) preprocessor.set_param("bilateral_kernel", filter_kernel) preprocessor.set_param("sigma_color", 9) segment = SegmentStage(5) labels = [] data = [] for img in files: label = img[-5:-4] labels.append(float(label)) image = cv2.imread(img, flags=1) canny, gray = preprocessor.run(image) # com.debug_im(image) conts = segment.run(canny, gray, image) try: