GithubHelp home page GithubHelp logo

grseb9s / bv Goto Github PK

View Code? Open in Web Editor NEW

This project forked from daleroberts/bv

0.0 1.0 0.0 7.9 MB

Quickly view satellite imagery, hyperspectral imagery, and machine learning image outputs directly in your iTerm2 terminal.

Python 100.00%

bv's Introduction

bv is a small tool to quickly view high-resolution multi-band imagery directly in your iTerm 2. It was designed for visualising very large images located on a remote machine over a low-bandwidth connection. It subsamples and compresses the image sends it over the wire as a base64-encoded PNG (hence the name "bv") that iTerm 2 inlines in your terminal.

Now, go and compare the above to old-school rendering or my other tool tv. Welcome to 2017!

Some Examples

Here are a number of examples that show how this tool can be used.

Big image over small connection

Display a 3.5 billion pixel single-band image (3.3GB) using only 467KB over a SSH connection.

Different band combinations

Display a six-band image (7.2GB) using only 1.1MB over a SSH connection. Here, we put bands 5-4-3 into the RGB channels using -b 5 -b 4 -b 3 (ordering matters) and set the width of the output image to be 600 pixels using -w 600.

You can also specify a single band to display (e.g., -b 1).

Subset images

You can subset images using gdal_translate syntax which is -srcwin xoff yoff xsize ysize. For example, only displaying a small 1000x1000 area of the same large image above.

This allows you to quickly identify regions of your image and then paste the same options into gdal_translate to complete your desired workflow. For example:

remote$ gdal_translate tasmania-2014.tif -b 5 -b 4 -b 3 -srcwin 12000 11000 1000 1000 -of PNG -ot UInt16 -scale 0 4000 ~/out.png
Input file size is 20000, 16000
0...10...20...30...40...50...60...70...80...90...100 - done.
remote$

Machine learning multi-class outputs with different color maps

Sometimes you might have a single-band image that only contains classes (integers). Different color maps can be applied to these single-band images using the -cm option and any choice from matplotlib's colormaps.

URLs

The bv tool can read from URLs (see the Trump image above). It can also parse URLs on stdin, this allows you to do things like this to quicky display available Landsat images roughly over Dubai.

remote$ landsat search --lat 25 --lon 55 --latest 3 | bv -urls -

Standard Input

Filenames can be read from stdin. For example:

ls -1 *.tif | bv -w 100 -

Compression

The level of compression can be changed using the -zlevel option (0-9).

Stacking images

If your bands are located in seperate images then you can stack them and display them in the RGB channels using

bv -stack RED.tif GREEN.tif BLUE.tif

There is also the -revstack option to do it in reverse order.

Subsampling algorithm

The subsampling algorithm can be changed using the -r option (same syntax as GDAL). The available subsamplings are:

  • Nearest
  • Average
  • Cubic Spline
  • Cubic
  • Mode
  • Lanczos
  • Bilinear

Alpha channel

For single-band images, you can specify the color value to set as the alpha channel. This is sometimes useful for machine learning outputs where you want to not display certain classes. You can add multiple of these with different values.

PDF, EPS, and PNG

The bv tool will display PDF, EPS, and PNG output inline with out any changes to those files. If you want to disable this behaviour you can pass the -nop option allow GDAL to subsample, etc.

TMUX Support

Configuration

You can save your default configuration by setting an alias in your ~/.profile file. For example, I do:

alias bv='bv -w 800'

Installation

It is just a single-file script so all you'll need to do it put it in your PATH. Dependencies are Python 3, GDAL 2, Numpy, Matplotlib, and iTerm 2. I've found that the best way to install these dependencies are:

# Python 3
brew install python3

# Numpy and matplotlib
pip3 install numpy matplotlib

# GDAL 2
brew install gdal --HEAD --without-python
pip3 install gdal

bv's People

Contributors

daleroberts avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.