if subject_ids == []: continue s = subject_ids[0] for task in annotations: if task["task"] == "T2": try: m = task["value"][0]["points"] if s not in markings: markings[s] = [m] else: markings[s].append(m) except (KeyError,IndexError) as e: pass for subject_id,points in markings.items(): fname = jungle.__image_setup__(subject_id) image_file = cbook.get_sample_data(fname) image = plt.imread(image_file) fig, ax1 = plt.subplots(1, 1) ax1.imshow(image) all_points = [] for a in points: for b in a: all_points.append((b["x"],b["y"])) if len(all_points) < 6: plt.close() continue
import matplotlib.pyplot as plt from matplotlib.collections import PolyCollection import numpy as np import csv import json from aggregation_api import AggregationAPI import matplotlib.cbook as cbook import sys # subject_id = int(sys.argv[1]) # minimum_users = int(sys.argv[2]) subject_id = 511723 project = AggregationAPI(348,public_panoptes_connection=True) subject_image = project.__image_setup__(subject_id) for minimum_users in [8]: print minimum_users fig, ax = plt.subplots() image_file = cbook.get_sample_data(subject_image) image = plt.imread(image_file) # fig, ax = plt.subplots() im = ax.imshow(image) all_vertices = [] with open("/tmp/348/4_ComplexAMOS/vegetation_polygons_heatmap.csv","rb") as f: polygon_reader = csv.reader(f)
def closest(aim,points): distance = float("inf") best_point = None for p in points: d = math.sqrt((aim[0]-p[0])**2+(aim[1]-p[1])**2) if d < distance: distance = d best_point = p return tuple(best_point) # fname = butterflies.__image_setup__(1120709)[0] for subject_id in butterflies.__get_subjects_in_workflow__(874): fname = butterflies.__image_setup__(subject_id)[0] print(fname) image_file = cbook.get_sample_data(fname) image = plt.imread(image_file) plt.imshow(image) plt.show() image = np.asarray(image,dtype=np.int) d1 = np.power(image[:,:,0] - 211,2) d2 = np.power(image[:,:,1] - 44,2) d3 = np.power(image[:,:,2] - 124,2) overall_d = np.power(d1+d2+d3,0.5) overall_d = np.uint8(255 - cv2.normalize(overall_d,overall_d,0,255,cv2.NORM_MINMAX))
from __future__ import print_function import matplotlib matplotlib.use('WXAgg') from aggregation_api import AggregationAPI import matplotlib.pyplot as plt import matplotlib.cbook as cbook import cv2 import numpy as np butterflies = AggregationAPI(1150, "development") butterflies.__setup__() # fname = butterflies.__image_setup__(1120709)[0] fname = butterflies.__image_setup__(1500825)[0] image_file = cbook.get_sample_data(fname) image = plt.imread(image_file) res = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) # kernely = cv2.getStructuringElement(cv2.MORPH_RECT,(10,2)) # dy = cv2.Sobel(res,cv2.CV_16S,0,2) # dy = cv2.convertScaleAbs(dy) # cv2.normalize(dy,dy,0,255,cv2.NORM_MINMAX) # ret,close = cv2.threshold(dy,0,255,cv2.THRESH_BINARY+cv2.THRESH_OTSU) # # t= image # _,contour, hier = cv2.findContours(close.copy(),cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_SIMPLE) # for cnt in contour: # x,y,w,h = cv2.boundingRect(cnt) # if ((w/h)>5) and (w>130) and (w < 160):
__author__ = 'ggdhines' from aggregation_api import AggregationAPI import matplotlib.cbook as cbook import matplotlib.pyplot as plt from skimage.color import rgb2gray from sklearn.cluster import DBSCAN import numpy as np import math import cv2 # subject_id = 918463 subject_id = 917160 project = AggregationAPI(11,"development") fname = project.__image_setup__(subject_id) #478758 #917091 def convex_hull(points): """Computes the convex hull of a set of 2D points. Input: an iterable sequence of (x, y) pairs representing the points. Output: a list of vertices of the convex hull in counter-clockwise order, starting from the vertex with the lexicographically smallest coordinates. Implements Andrew's monotone chain algorithm. O(n log n) complexity. """ # Sort the points lexicographically (tuples are compared lexicographically). # Remove duplicates to detect the case we have just one unique point. points = sorted(list(set(points)))