Setting default parameters for imshow in pyplot

I find default visualization settings for images in matplotlib inconvenient. Usually I prefer to see images in grayscale color map and without smoothing. Thus I see actual data without distortions. Grayscale is easier to understand. 1 2 3 import matplotlib.pyplot as plt plt.rcParams['image.cmap'] = 'gray' plt.rcParams['image.interpolation'] = 'nearest' Compare default colors and interpolation: and after applying the settings:

November 23, 2014 · SergeM

Loading numpy array from string

Okay children, today we learn how to convert text to numpy matrix. Source is [here](http://docs.scipy.org/doc/numpy/reference/generated/numpy.loadtxt.html" target="_blank). # loading modules import numpy from StringIO import StringIO # Using StringIO as a file-like wrapper over text I0 = numpy.loadtxt(StringIO(""" 0 0 0 0 0 0 0 0.5000 0 0 0 0 1.0000 0 0 0 0 0.5000 0 0 0 1.0000 0 0 0 0 0.5000 0 0 0 0 0.5000 1.0000 0 0 0 0 0 0 0"...

November 17, 2014 · SergeM

Quiver for optical flow

Standard matlab’s quiver function has axis origin in left bottom corner, however, images have origin in top left corner. To display optical flow vector field consistenly i use the following fucntion: function [ output ] = quiver_flow( u, v ) %QUIVER_FLOW Displays quiver for optical flow % SMatyunin2014 output = quiver( u, v, 0); axis ij; end

November 6, 2014 · SergeM

Save Ipython notebook as script with the same filename

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 # creating a variable theNotebook with the name of notebook # source: http://stackoverflow.com/a/23619544 # In[1]: %%javascript var kernel = IPython.notebook.kernel; var thename = window.document.getElementById("notebook_name").innerHTML; var command = "theNotebook = " + "'"+thename+"'"; kernel.execute(command); # saving to a directory 'backup'. create the directory if it doesn't exist # source http://stackoverflow....

September 21, 2014 · SergeM

Python equivalent of interp2

I wrote python version of interp2(z, xi, yi,’linear’) from matlab https://github.com/serge-m/pyinterp2

September 16, 2014 · SergeM

tikz cookbook

Drawing on an image with TikZ Drawing label on figure (using tikz) \begin{tikzpicture} \node[anchor=south west,inner sep=0] at (0,0) {\includegraphics[trim={600px 200px 50px 200px},clip, width=1\linewidth]{images/DP_10150_simpleCombinedBasedOnDPlen.exe_scale1_blank/frm00001}}; %\draw[white,fill=white] (0.0,0.0) rectangle (0.5,0.5); \node[minimum size=.6cm, fill=white,anchor=south west] at (0.0,0.0){а}; \end{tikzpicture}

July 16, 2014 · SergeM

Theano

_Intro __Theano_ is a Python library that allows you to define, optimize, and evaluate mathematical expressions involving multi-dimensional arrays efficiently. Check gpu is workingSource: [http://deeplearning.net/software/theano/tutorial/using_gpu.html](http://deeplearning.net/software/theano/tutorial/using_gpu.html) Test script: :::: from theano import function, config, shared, sandbox import theano.tensor as T import numpy import time <span class="n">vlen</span> <span class="o">=</span> <span class="mi">10</span> <span class="o">*</span> <span class="mi">30</span> <span class="o">*</span> <span class="mi">768</span> <span class="c"># 10 x #cores x # threads per core</span> <span class="n">iters</span> <span class="o">=</span> <span class="mi">1000</span> <span class="n">rng</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">....

June 5, 2014 · SM!

multiple "windows" in one linux terminal

use “screen” utility ctrl-a-p - switch ctrl-a-c - new ctrl-a-Q - remove freeze ctrl-a-s - freeze ctrl-a-S - split, but doesn;t work see also: using tmux

May 21, 2014 · SM!

Migrating from SVN to Git and Mercurial

There is a lot of answers here: http://stackoverflow.com/questions/79165/how-to-migrate-svn-with-history-to-a-new-git-repository I found rather useful [this one](http://stackoverflow.com/a/9316931" target="_blank). A guy made a script according to proposed instructions: https://github.com/onepremise/SGMS This script will convert projects stored in SVN with the following format: /trunk /Project1 /Project2 /branches /Project1 /Project2 /tags /Project1 /Project2 This scheme is also popular and supported as well: /Project1 /trunk /branches /tags /Project2 /trunk /branches /tags Each project will get synchronized over by project name:...

January 8, 2014 · SergeM

Books

There must be some kind of rating here. Maybe later… Done The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life by Mark Manson. Download at amazon. Read 2022. It seems to me this is a shorter, a bit more rude version of “Seven habits” for millennials. I like the book. I guess it is even too short for me to unpack some of the ideas while I was listening to the audio version....

November 29, 2013 · SergeM