This file contains 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
normalize = lambda x: (255 / (x.max() - x.min())) * (x - x.min()) | |
smooth = lambda x: ndimage.convolve(x, np.ones([3,3])/9) | |
def threshold_mask(img, threshold=150): | |
gray = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY) | |
mask = np.ones(gray.shape).astype(np.uint8) | |
mask[gray < threshold] = 0 | |
return mask | |
def scanline_mask(imask): |
This file contains 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 cv2 | |
from skimage.morphology import binary_opening | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
import matplotlib | |
matplotlib.style.use('ggplot') | |
%matplotlib inline | |
This file contains 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
#!/bin/sh | |
"exec" "twxec" "-e" "filter_stream()" "$0" "$@" | |
import oauth2 as oauth | |
from trickle import twitter as tw | |
{{docstring "Make sure you have registered an application with Twitter in order to obtain your credentials. Once you have them, start streaming tweets using one of the filtering parameteres below"}} | |
app_key = {{string Twitter_App_Key}} | |
app_secret = {{string Twitter_App_Secret}} |
This file contains 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 base64 as b64 | |
import numpy as np | |
import cv2 | |
import matplotlib.pyplot as plt | |
from ipywidgets import interact, interactive, fixed | |
from IPython.display import Image, display | |
import ipywidgets as widgets | |
from itertools import tee, izip | |
WINDOW_SIZE = 41 # size of window to use when computing averages. Endpoint images outside |
This file contains 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
#!/bin/sh | |
"exec" "twxec" "-e" "filter_stream()" "$0" "$@" | |
import oauth2 as oauth | |
from trickle import twitter as tw | |
{{docstring "Make sure you have registered an application with Twitter in order to obtain your credentials. Once you have them, start streaming tweets using one of the filtering parameteres below"}} | |
app_key = {{string Twitter_App_Key}} | |
app_secret = {{string Twitter_App_Secret}} |
This file contains 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 cv2 | |
import numpy as np | |
%matplotlib inline | |
import matplotlib.pyplot as plt | |
def buffer_coastline(img, threshold=135): | |
arr = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY) | |
mask = np.ndarray(arr.shape + (3,)).astype(np.uint8) | |
below = arr < threshold |
This file contains 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 pandas as pd | |
areas = [] | |
for i, img in enumerate(found_objects): | |
for r, reg in enumerate(img): | |
for cnt in reg['contours']: | |
areas.append((cv2.contourArea(cnt), r, i)) | |
df = pd.DataFrame(data = areas, columns=['area', 'dock', 'image']) |
OlderNewer