• Stars
    star
    228
  • Rank 174,290 (Top 4 %)
  • Language
    Python
  • Created almost 8 years ago
  • Updated over 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

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

More Repositories

1

itermplot

An awesome iTerm2 backend for Matplotlib, so you can plot directly in your terminal.
Python
1,491
star
2

tv

Quickly view (satellite) imagery directly in your terminal using Unicode 9.0 characters and true color.
Python
399
star
3

math-finance-cheat-sheet

Mathematical finance cheat sheet.
TeX
228
star
4

hdmedians

High-dimensional medians (medoid, geometric median, etc.). Fast implementations in Python.
Python
71
star
5

pypar

Efficient and scalable parallelism using the message passing interface (MPI) to handle big data and highly computational problems.
Python
69
star
6

black-scholes

Black Scholes formula and greeks
R
36
star
7

heston

Implementations of the Heston stochastic volatility model
R
25
star
8

poisson

Solve Poisson equation on arbitrary 2D domain using the finite element method.
Python
22
star
9

hdstats

A library of multivariate, high-dimensional statistics, and time series algorithms for spatial-temporal stacks.
Python
17
star
10

s2cloudmask

Sentinel-2 Cloud and Shadow Detection using Machine Learning
Python
14
star
11

datacube-2nd-order-stats

2nd-order robust temporal statistics of Earth observations
Python
9
star
12

heat

Example solvers for the heat equation
C
8
star
13

pbs-examples

PBS script examples
Shell
4
star
14

obstacle-problem

Solve an obstacle problem (i.e, a partial differential equation with constraints)
Python
4
star
15

nrt-predict

Predict from NRT data
Python
3
star
16

inteq-laplace

Boundary integral equation solver for 2D Laplace equation
Python
3
star
17

opendatacube-pixeldrill

Show/extract time series in temporal stack of satellite imagery using a GUI
Python
3
star
18

luigi-examples

Some luigi examples
Python
2
star
19

vgfd

Finite difference solver for the 'Variance Gamma' partial-integro differential equation (PIDE)
MATLAB
2
star
20

heston-qmc

Exact simulation and Quasi Monte Carlo for the Heston stochastic volatility model
C++
1
star
21

ruin-tstable

Finite-time ruin problem for tempered stable processes
C++
1
star
22

binomial

Binomial models
MATLAB
1
star
23

ps_vlm

Measurement of vertical land motion using Sentinel-1 Synthetic Aperture Radar (SAR) observations and a persistent scatterer approach
Python
1
star
24

volmodels

Stochastic volatility models
C++
1
star
25

py-dwt

A simple ctypes wrapper around the GSL wavelet functions.
Python
1
star