Skip to content

Instantly share code, notes, and snippets.

View dbuscombe-usgs's full-sized avatar
🎯
Focusing

Daniel Buscombe dbuscombe-usgs

🎯
Focusing
View GitHub Profile
@dbuscombe-usgs
dbuscombe-usgs / specnoise.m
Created July 26, 2013 02:35
3D spectral noise in Matlab with specified autocorrelation
imfft=fftshift(fftn(randn(cols,rows,dep)));
mag=abs(imfft);
phase=imfft./mag;
[xi,yi,zi]=meshgrid(1:rows,1:cols,1:dep);
radius=sqrt(xi.^2+yi.^2+zi.^2);
radius(cols/2+1,rows/2+1,dep/2+1)=1;
filter=1./(radius.^factor);
im=real(ifftn(fftshift(filter.*phase)));
%im=ifftn(fftshift(filter.*phase),'symmetric');
im=rescale(im,0,1);
@dbuscombe-usgs
dbuscombe-usgs / mpt_examples.m
Created July 26, 2013 02:38
Computational geometry with Matlab and MPT
V=volume(P);
% return a vector of the number of sides in each polytope
[H,K]=double(P);
[numsides, Cncols] = cellfun(@size, H);
% return a vector of polytope radii
[xyz,Rad] = chebyball(P);
% find the extrema of each polytope in P
@dbuscombe-usgs
dbuscombe-usgs / shadowscan.sh
Created July 26, 2013 02:45
reconstruct the three-dimensional shape of an object in a scene in a very inexpensive way using shadow-casting http://thezestyblogfarmer.blogspot.com/2011/03/wrapping-and-interfacing-compiled-code.html
defined()
{
[ ${!1-X} == ${!1-Y} ]
}
args=("$@") # get arguments passed to the program
# if no arguments, IMAGES and CNTRST will be empty otherwise will be filled with the arguments
defined args && IMAGES=${args[0]} # first = sample image location e.g. /home/daniel/Desktop/shadow_scanning/sample/
defined args && CNTRST=${args[1]} # second = contrst values - no more than four! e.g. 30.35.40.45
@dbuscombe-usgs
dbuscombe-usgs / Rspat.c
Created July 26, 2013 02:50
Program for spatial correlogram of an image, in C
#include <stdio.h>
#include "cv.h"
#include "highgui.h"
int main( int argc, char** argv )
{
time_t t1,t2; // initiate timer
(void) time(&amp;t1);
// define some variables
IplImage *im = 0;
@dbuscombe-usgs
dbuscombe-usgs / serialcontrol.py
Created July 26, 2013 02:54
Controlling a serial device with Python
import os
import pprint
import sys
import wx
# use wx with mpl is with the WXAgg backend
import matplotlib
matplotlib.use('WXAgg')
from matplotlib.figure import Figure
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigCanvas, NavigationToolbar2WxAgg as NavigationToolbar
import numpy as npy
@dbuscombe-usgs
dbuscombe-usgs / fix
Created July 26, 2013 02:57
Batch GIMP script for auto-sharpen, white-balance and colour enhance
(define (batch-auto-fix pattern
radius
amount
threshold)
(let* ((filelist (cadr (file-glob pattern 1))))
(while (not (null? filelist))
(let* ((filename (car filelist))
(image (car (gimp-file-load RUN-NONINTERACTIVE
filename filename)))
(drawable (car (gimp-image-get-active-layer image))))
@dbuscombe-usgs
dbuscombe-usgs / flowerbed.m
Last active December 20, 2015 06:29
draw a flower bed using appollonian gaskets
function flower_bed(n)
% n is the number of internal circles (must be greater than 2 - greater than 10 looks weird)
h = figure;
hAxs = axes('Parent',h);
axis equal;
grid off;
hold on;
V = 0:2*pi/n:2*pi;
sudo mkdir ~/.config/lxsession
sudo mkdir ~/.config/lxsession/LXDE
sudo nano ~/.config/lxsession/LXDE/autostart
lxterminal --geometry=50x10 --title="MY TITLE" -e python /usr/bin/my_script.py
lxshortcut -o ~/Desktop/my_launcher.desktop