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
# Superpixel segmentation approach that seems to give pretty good contiguous segments. | |
# (SLIC and quickshift don't seem to guarantee contiguity). The approach is to get initial | |
# segments from SLIC, use the centroid of each as a marker for watershed, then clean up. | |
import os, argparse | |
from skimage import segmentation | |
from skimage.future import graph | |
import cv2, numpy | |
import tempfile | |
import random |
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 numpy | |
def generate_max_zero_probabilities(maxZ): | |
maxZ += 1 | |
row1 = numpy.array(list(map(lambda x: pow(2,-(x+1)),range(maxZ)))) | |
row1_cum = row1.cumsum() - row1 # non-inclusive cumsum | |
yield (1,row1) | |
prev_row = row1 | |
prev_row_cum = row1_cum |
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
with my_columns as | |
(select table_name,array_agg(json_build_object('column_name', column_name, 'is_nullable', is_nullable, 'data_type', data_type, 'ordinal_position', ordinal_position)) cols | |
from information_schema.columns | |
where table_schema='public' | |
group by table_name), | |
my_fks as | |
(select distinct r.constraint_name, | |
k.table_name from_table, | |
c.table_name to_table | |
from information_schema.key_column_usage k |
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
select 'CREATE OR REPLACE VIEW dp_' || table_name || | |
E' AS\nSELECT ' || array_to_string(array_agg(format('%s',column_name)),E',\n ') || | |
E'\nFROM ' || table_name || E';\n' | |
from information_schema.columns | |
where table_schema = 'public' | |
group by table_name; |