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
| #!/usr/bin/env python | |
| """Convert an SVG file to a PNG file.""" | |
| from argparse import ArgumentParser | |
| import subprocess | |
| import os.path | |
| def main(): |
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 | |
| import cairo | |
| def polygon_mask(polygon): | |
| assert polygon.geom_type == 'Polygon' | |
| minx, miny, maxx, maxy = polygon.bounds | |
| minx, miny = numpy.floor([minx, miny]).astype(numpy.int32) | |
| maxx, maxy = numpy.ceil([maxx, maxy]).astype(numpy.int32) |
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 rasterio | |
| from rasterio import features | |
| import shapely | |
| from shapely.geometry import Point, Polygon | |
| def mask_to_polygons_layer(mask): | |
| all_polygons = [] | |
| for shape, value in features.shapes(mask.astype(np.int16), mask=(mask >0), transform=rasterio.Affine(1.0, 0, 0, 0, 1.0, 0)): | |
| return shapely.geometry.shape(shape) | |
| all_polygons.append(shapely.geometry.shape(shape)) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 | |
| def outline_to_mask(line, x, y): | |
| """Create mask from outline contour | |
| Parameters | |
| ---------- | |
| line: array-like (N, 2) | |
| x, y: 1-D grid coordinates (input for meshgrid) |
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
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| """ | |
| Created by Stephan Hügel on 2017-03-02 | |
| The MIT License (MIT) | |
| Copyright (c) 2017 Stephan Hügel | |
| Permission is hereby granted, free of charge, to any person obtaining a copy | |
| of this software and associated documentation files (the "Software"), to deal | |
| in the Software without restriction, including without limitation the rights | |
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
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
| # Combine multiple images into one. | |
| # | |
| # To install the Pillow module on Mac OS X: | |
| # | |
| # $ xcode-select --install | |
| # $ brew install libtiff libjpeg webp little-cms2 | |
| # $ pip install Pillow | |
| # | |
| from __future__ import print_function |
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
| #!/usr/bin/python | |
| # | |
| # Delete the label image from an Aperio SVS file. | |
| # | |
| # Copyright (c) 2012-2013 Carnegie Mellon University | |
| # All rights reserved. | |
| # | |
| # This program is free software: you can redistribute it and/or modify | |
| # it under the terms of the GNU Lesser General Public License as | |
| # published by the Free Software Foundation, version 2.1. |
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
| #!/usr/bin/env ruby | |
| require 'selenium-webdriver' | |
| wd = Selenium::WebDriver.for :remote, url: 'http://10.3.1.7:4444/wd/hub', desired_capabilities: :chrome | |
| wd.navigate.to 'https://snipt.net/restrada/python-selenium-workaround-for-full-page-screenshot-using-chromedriver-2x/' | |
| # Get the actual page dimensions using javascript | |
| # | |
| width = wd.execute_script("return Math.max(document.body.scrollWidth, document.body.offsetWidth, document.documentElement.clientWidth, document.documentElement.scrollWidth, document.documentElement.offsetWidth);") |