Showing posts with label photography. Show all posts
Showing posts with label photography. Show all posts

Saturday, 12 October 2013

Kivy python script for capturing displaying webcam

Kivy is very cool. It allows you to make graphical user interfaces for computers, tablets and smart phones ... in Python. Which is great for people like me. And you, I'm sure. And it's open source, of course.

Today was my first foray into programming using Kivy. Here was my first 'app'. It's not very sophisticated, but I find Kivy's documentation rather impenetrable and frustratingly lacking in examples. Therefore I hope more people like me post their code and projects on blogs.

Right, it detects and displays your webcam on the screen, draws a little button in the bottom. When you press that button it takes a screengrab and writes it to an image file. Voila! Maximise the window before you take a screen shot for best effects.



Wednesday, 14 August 2013

Doing Spectral Analysis on Images with GMT

Mostly an excuse to play with, and show off the capabilities of, the rather fabulous Ipython notebook! I have created an Ipython notebook to demonstrate how to use GMT to do spectral analysis on images.

This is demonstrated by pulling wavelengths from images of rippled sandy sediments.

GMT is command-line mapping software for Unix/Linux systems. It's not really designed for spectral analysis in mind, especially not on images, but it is actually a really fast and efficient way of doing it! 

This also requires the convert facility provided by Image Magick. Another bodacious tool I couldn't function without.

My notebook can be found here.

Fantastic images of ripples provided by http://skeptic.smugmug.com

Saturday, 5 June 2010

Turn your OGV movie section into a cropped animated GIF

An example from a recent project

 # make directory for output jpg  
mkdir out_pics
# section to the ogv video file into jpegs
mplayer -ao null -ss 00:00:03 -endpos 50 beautiful_movie.ogv -vo jpeg:outdir=out_pics
cd out_pics
# loop over each image and crop into desired rectangle
for image in *.jpg
do
convert $image -crop 600x600+350+135 "$image crop.tiff"
done
# turn into an animated gif
convert -page 600x600+0+0 -coalesce -loop 0 *.tiff beautiful_animation.gif

Unlock the power of ImageMagick to HDRI

My primary motivation to do this has been to use ImageMagick for Fast Fourier Transforms, which have a myriad of applicability in image processing and filtering

First, you have to install perlmagick. Using apt,
 sudo apt-get install perlmagick  


Then the perl libraries
 sudo apt-get install libperl-dev  


Install the rather magnificent fftw libraries
 sudo apt-get install libfftw3-dev fftw-dev  


wget the source code, untar, move it, cd home
 wget ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick.tar.gz   
tar xvfz ImageMagick.tar.gz
mv ImageMagick-6.6.0-8 $HOME
cd $HOME/ImageMagick-6.6.0-8


Install (see here for instructions)
 make distclean   
./configure --enable-hdri LDFLAGS='-L/usr/local/lib -R/usr/local/lib'


see also here for a bug fix, and also see here for instructions

make & sudo make install
make check


To see whether the fft commands are working properly, you could issue the following:
 if [ -s lena.png] #check to see if the file exists  
then
# do fft and ifft roundtrip
convert lena.png -fft -ift lena_mp_roundtrip.png
else
#first download
wget http://optipng.sourceforge.net/pngtech/img/lena.png
#then convert
convert lena.png -fft -ift lena_mp_roundtrip.png
fi


see here for further information on fft transforms with, and watch your world spin faster