Tuesday, November 23, 2010

Interesting thought on night sky photography

Background: it's super hard to get sharp, bright photos of the night sky. With decent ISO and aperture, the exposures get long enough to cause the stars to streak across the picture. The professional approach would be to get a star tracking rig for $$$$, OR....

Take, say, 100 10-second exposures at high sensitivity, find the 2-d cross-correlation function between each pair of consecutive images (assuming you have nothing else in the FOV, or if so then mask it out), and shift and co-add them? If the noise is additive and normally distributed you can continue ad nauseum–the SNR is proportional to sqrt(N) where N is the number of integrations.


Sunday, May 02, 2010

CUDA book

Kirk & Hwu: Progamming Massively Parallel Processors (Morgan Kaufmann) just arrived! Only concern so far is I'm a quarter through the thing and it's still explaining cudaMalloc() and cudaMemcpy(). Nothing wrong with a solid foundation I suppose. The highlight thus far: their main recurring example is a matrix-matrix multiplication function.

Wednesday, September 30, 2009

du -sh *

Linux disk space usage, in human readable form. Nuf said.

Thursday, September 03, 2009

std::nth_element

Ever wanted to know what the N:th element in a sorted version of the sequence [first,last) is, without sorting the whole thing? I sure did. Unfortunately I didn't know about std::nth_element!
std::nth_element( first, nth, last );
Paraphrasing sgi.com, after this function is applied, nth is guaranteed to be the same as if the entire sequence was sorted. Meanwhile, non of the (first,nth] elements are larger than the nth element, and so logically the opposite goes for the [nth+1,last) elements. This method does less work than both std::sort and std::partial_sort, and thus is likely to be faster.

Tuesday, January 06, 2009

float2 and float3 in Maya Python API

Staying true to form, Autodesk sure has made a mess of the Maya Python API. Something I ran into recently was dealing with float2:s (for MFnMesh::getUVAtPoint()). Turns out you need to go through MScriptUtil like so:
import maya.OpenMaya as om
# this creates the float2
pArray = [0,0]
x1 = om.MScriptUtil()
x1.createFromList( pArray, 2 )
uvPoint = x1.asFloat2Ptr()
# (call to OpenMaya.MFnMesh.getUVAtPoint( ..., uvPoint, ... ) 
# goes here)
# retrieve results
uv0 = om.MScriptUtil.getFloat2ArrayItem( uvPoint, 0, 0 )
uv1 = om.MScriptUtil.getFloat2ArrayItem( uvPoint, 0, 1 )

Curiously enough the '2' in float2ptr and float2array refers to 2-dimensional arrays, hence the extra 0 in the call to the latter. We're only dealing with float2& (which typedefs to float[2]) in our getUVAtPoint call, but frankly: did you expect anything else than a hackfest when you popped that Maya 2009 box open?