Git Product home page Git Product logo

tv's Introduction

tv ("textview") is a small tool to quickly view high-resolution multi-band imagery directly in your terminal. It was designed for working with (very large) satellite imagery data over a low-bandwidth connection. For example, you can directly visualise a Himawari 8 (11K x 11K pixel) image of the Earth directly from its URL:

It is built upon the wonderful GDAL library so it is able to load a large variety of image formats (GeoTiff, PNG, Jpeg, NetCDF, ...) and subsample the image as it reads from disk so it can handle very large files quickly. It has the ability to read filenames (or URLs) from stdin and load files directly from URLs without writing locally to disk. Command line options are styled after gdal_translate such as:

  • -b to specify the bands (and ordering) to use,
  • -srcwin xoff yoff xsize ysize to view a subset of the image,
  • -r to specify the subsampling algorithm (nearest, bilinear, cubic, cubicspline, lanczos, average, mode).

tv is completely implemented in Python 3 using only Numpy and GDAL 2.0.

My rendering approach is different from other tools such as hiptext as I use:

This means that you get amazingly better results as long as your terminal and font supports it. Here is a comparison between hiptext (left) and tv (right) using their benchmark image of Barack Obama using the standard MacOS font 'Menlo Regular' at size 11 in iTerm 2.0.

You can easily zoom in to get better detail or make the output smaller.

You can quickly view very large files over low-bandwidth connections (e.g., mobile). For example, visualising a 46GB single-band 176000 x 140000 pixel image using nearest neighbour subsampling located on the raijin supercomputer.

It can detect URLs on the standard input which allows you to use it in combination with other tools such as landsat-util to quickly visualise thumbnails before you perform a full download.

You can directly give a URL on the command line.

If you have a image with more than 3 bands (channels), you can specify the ordering and the bands that you would like to load into the RGB channels.

You can stack multiple images into the red/green/blue channel or handle multiple subsets of a NetCDF file.

If you really want to throttle back the number of unicode characters used (e.g., if your font or terminal doesn't support many unicode characters), you can do it with a command line option. The following example shows how to use only the block character or a half-height character as well.

Using a GNU parallel, you can do silly things like create a low-fi animation of the Earth viewed from the Himawari-8 satellite.

parallel --willcite --tty --header : tv -w 60 -urls http://himawari8-dl.nict.go.jp/himawari8/img/D531106/thumbnail/550/2016/06/{dy}/{hr}{tenmin}000_0_0.png  ::: dy 06 ::: hr 06 ::: tenmin {0..5}

FAQ

How do I install it?

tv is now a Python package so you can install it directly using pip if you have GDAL 2.x installed.

To install these dependencies on a Mac with homebrew do:

brew install gdal --with-complete --without-python --HEAD
brew install python3

pip3 install tv

On Ubuntu Linux do:

sudo apt install python3 libgdal-dev
export CPLUS_INCLUDE_PATH=/usr/include/gdal
export C_INCLUDE_PATH=/usr/include/gdal

pip3 install tv

Does it work on Windows using PuTTY?

Yes if you install a patched version of PuTTY and use the Deja Vu Mono Book which has support for Unicode 9.0 block characters.

If you do not have administrator rights on you Windows machine, you can load the Deja Vu font for your login session using the regfont tool.

Does it support TMUX?

If you use TMUX, you'll need version >2.2 for true color support. Here is a description on how to enable true color in TMUX. Personally, I've found that the best way is to place these lines at the end of your .tmux.conf file:

set -g default-terminal "screen-256color"
set -ga terminal-overrides ",xterm-256color:Tc"

tv's People

Contributors

daleroberts avatar dschep avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tv's Issues

ModuleNotFoundError: No module named 'gdal'

Traceback (most recent call last):
  File "/usr/bin/tv", line 33, in <module>
    sys.exit(load_entry_point('tv==0.1', 'console_scripts', 'tv')())
  File "/usr/bin/tv", line 25, in importlib_load_entry_point
    return next(matches).load()
  File "/usr/lib/python3.9/importlib/metadata.py", line 77, in load
    module = import_module(match.group('module'))
  File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 972, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/usr/lib/python3.9/site-packages/tv/__init__.py", line 11, in <module>
    import gdal
ModuleNotFoundError: No module named 'gdal'

When running tv.

Can't compile gdal==2.0.2: missing "cpl_vsi_error.h" header file

Linux 3.16.0-4-amd64 #1 SMP Debian 3.16.43-2 (2017-04-30) x86_64 GNU/Linux

$ gdal-config --version $ 2.0.2 $ gdal-config --clfags $ -I/usr/local/include

When running # pip3 install tv it fails with this error code:

extensions/gdal_wrap.cpp:3172:27: fatal error: cpl_vsi_error.h: No such file or directory

So if this is a header included in 2.2.0, but not 2.0.2, then the documentation for tv should reflect that.

PDF

PDF with text look weird. Check
this one (it's in Russian, but you can see the difference anyway)

`tv` doesn't use Unicode 13's 2x3 mosaics

Since Unicode 13 was released, it's possible to use 2x3 mosaics (as implemented in TRS-80 computers and Teletext terminals) and other characters that could make nicer images.

I can add them to the CHARS constant after the 2x2 characters, but I don't know exactly how the character selection works. We could also use extended smoothed mosaics (also from Teletext) or PETSCII and ATASCII characters added in version 13.

Cannot run/build tv

Having troubles run tv app on macOS Sierra 10.12.6 after following the installation instructions:
brew install gdal --with-complete --without-python --HEAD
brew install python3
pip3 install tv

tv docs/obama_eye.png
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/osgeo/gdal_array.py", line 18, in swig_import_helper
fp, pathname, description = imp.find_module('_gdal_array', [dirname(file)])
File "/usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/imp.py", line 296, in find_module
raise ImportError(_ERR_MSG.format(name), name=name)
ImportError: No module named '_gdal_array'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/bin/tv", line 11, in
sys.exit(main())
File "/usr/local/lib/python3.6/site-packages/tv/cli.py", line 4, in main
tv.main()
File "/usr/local/lib/python3.6/site-packages/tv/init.py", line 314, in main
show_fn(img, **kwargs)
File "/usr/local/lib/python3.6/site-packages/tv/init.py", line 248, in show_fn
show_fd(gdal.Open(fn), *args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/tv/init.py", line 243, in show_fd
show(rbs, xoff, yoff, ow, oh, w, h, r, slowout)
File "/usr/local/lib/python3.6/site-packages/tv/init.py", line 178, in show
buf_ysize=h, resample_alg=SAMPLING[r])
File "/usr/local/lib/python3.6/site-packages/osgeo/gdal.py", line 2528, in ReadAsArray
from . import gdalnumeric
File "/usr/local/lib/python3.6/site-packages/osgeo/gdalnumeric.py", line 1, in
from osgeo.gdal_array import *
File "/usr/local/lib/python3.6/site-packages/osgeo/gdal_array.py", line 28, in
_gdal_array = swig_import_helper()
File "/usr/local/lib/python3.6/site-packages/osgeo/gdal_array.py", line 20, in swig_import_helper
import _gdal_array
ModuleNotFoundError: No module named '_gdal_array'

Then I tried to reinstall with:
brew upgrade python3
pip3 install --ignore-installed tv

This time install of tv fails with:
extensions/gdal_wrap.cpp:9305:7: error: use of undeclared identifier 'VSICurlClearCache'
VSICurlClearCache();
^
1 warning and 1 error generated.
error: command 'clang' failed with exit status 1

----------------------------------------

Command "/usr/local/opt/python3/bin/python3.6 -u -c "import setuptools, tokenize;file='/private/var/folders/pc/ybpzm2q10xj0tqkxkvv9xf640000gn/T/pip-build-1e_84bil/gdal/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /var/folders/pc/ybpzm2q10xj0tqkxkvv9xf640000gn/T/pip-l0m0yz7b-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/pc/ybpzm2q10xj0tqkxkvv9xf640000gn/T/pip-build-1e_84bil/gdal/

What can be done about this? Thanks

distortion

hi!
i'm trying out this amazing idea.

Using this URL:
http://hirise-pds.lpl.arizona.edu/PDS/EXTRAS/RDR/ESP/ORB_011400_011499/ESP_011491_0985/ESP_011491_0985_MIRB.abrowse.jpg

I'm getting quite a bit of distortion:

screenshot 2017-02-24 09 20 25

Do I maybe have to adapt something in my Terminal settings? I'm using iterm2 (v 3.0.14 on macOS 10.11.6), which is quite complex with a lot of settings and I'm not very firm on terminal technology, so I might well miss something, but I can say that the terminal emulation is set to:

  • Character Encoding: Unicode (UTF-8)
  • Report Terminal Type: xterm-256color

Maybe my funky zsh prompt is messing things up?

Thanks for any help!

License

Hey,
What is the license?

libsixel support

Any plans to support libsixel? I think this would allow for a much greater image quality than is currently available.

Raspberry Pi?

I've burned quite a bit of time trying to get this to compile on the Raspberry Pi. I think my desire to compile 'tv' exceeds my ability. If I had to guess at the root problem, the GDAL that is part of Raspbian is v1.x and you're using v2.x. (I'm not entirely sure why I need geospatial processing to covert images to ANSI?)

Just venting I guess. If you can create a Raspberry Pi binary (or a reduced version that doesn't require GDAL), man, that would be totally awesome. Otherwise, it looks like I'll have to build out a Linux box somewhere if I want to move forward with this.

PS: I've looked at a few of these conversion routines so far. Some of them still have the basic 'image to ASCII' routine happening on top of the color blocks. None of them seemed to be intelligently using character sets like you're doing. (Although I wondered why, perhaps, you weren't using something that would give a good dither to mix two colors in one block?)

Thank you for your work.
Appreciative, but obviously reaching for something beyond my grasp right now.

Obama pic gives error

(stable) └─❱❱❱ tv -url https://github.com/jart/hiptext/blob/master/obama.jpg                                                1 ⏎  +5819 9:27 ❰─┘
Traceback (most recent call last):
  File "/Users/klay6683/bin/tv", line 309, in <module>
    show_url(url, **kwargs)
  File "/Users/klay6683/bin/tv", line 259, in show_url
    show_fd(gdal.Open(mmapfn), *args, **kwargs)
  File "/Users/klay6683/miniconda3/envs/stable/lib/python3.5/site-packages/osgeo/gdal.py", line 2943, in Open
    return _gdal.Open(*args)
RuntimeError: `/vsimem/97d993bcdb314feda6929c4b4ba4060e' not recognized as a supported file format.

Using iterm2.app v3.0.14 on macOS 10.11.6

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.