“This paper discusses piece-wise polynomial interpolators used in audio resampling and presents new low-order designs that are optimized for high-quality resampling of oversampled audio. Source code and useful tables for using the interpolators are included.”
Tulkaa nälissänne, sillä tarjolla tulee olemaan runsaasti pellon antimia. / Come hungry, we will serve plenty of food harvested from the field.
Villa Pukkilassa on rantasauna, joten saunakaljat ja pyyhkeet kannattaa ottaa mukaan. / There is a sauna, so bring your own beers and towels.
Yöpymismahdollisuus on, mutta paikka pitää olla tyhjänä ja siivottuna aamukymmeneen mennessä. / You can sleep in Villa Pukkila, but the place must be clean and everybody must be out by 10:00 in the morning.
Sometimes I get an idea that I think may be worth something, maybe not much, but something. But then I forget it. Better write it down, here.
2010-09-06
Efficient two-dimensional convolution with arbitrary rotationally symmetric kernels. A 2-d Gaussian kernel has the nice property that a rotationally symmetric kernel is achieved by successive horizontal and vertical convolutions. This makes 2-d convolution with Gaussian kernels very cheap, and “Gaussian blur” has thus become, partially for this reason, a popular operation in image processing. No other kernel with this property exists when the kernel is limited to real numbers, as the kernel function must satisfy . But, if one allows the kernel to consist of complex numbers, then an appropriately phased version of the Gaussian kernel also satisfies the condition. The condition may be broken down into a magnitude condition and a phase condition that must both be satisfied. The magnitude condition reads , meaning that the kernel must have a Gaussian function as its magnitude function. Because in multiplication of complex numbers the phases are summed, the phase (argument) condition reads , with the shorthand . The only family of functions to satisfy this is . So now we would be able to write such phased Gaussian functions. The actual idea: The output from different kernels from the phased Gaussian family could be combined by a complex-weighted sum to create approximations of arbitrary rotationally symmetric kernels. At the end one could either use the magnitude or the real or imaginary part of the sum as the real number output.
2010-05-18
A theory on how molecules inside a cell manage to be in the part of the cell where they are needed. If macromolecules A and B bind to each other and B and C also bind to each other, and the two binding reactions need not compete with one another, then obviously A and C will also end up close together, via B. This must be a very common way to create a tight organization between macromolecules. But what about when a more loose organization is required, let’s say when the rather freely diffusing tRNA’s are needed where translation takes place. It seems unlikely that the contents of a cell would be an inefficient homogeneous porridge of macromolecules. Perhaps affinities between macromolecules brings about organization. To describe the affinities between N species of macromolecules, one would need at least an N x N triangular matrix of affinity constants. It would be interesting to simulate such a system, and to see if compartmentalization takes place by itself without boundaries. If a macromolecule of an unknown purpose is found to have affinity to several components of a cellular process, then the guess can be made that it probably contributes to the process somehow. These affinities probably wouldn’t need to be very strong. Some types of metabolic and transport systems could perhaps be shown to be more effective in an internally organized cell.
2010-04-07
A directional microphone that is a 3D configuration of multiple omnidirectional microphone elements. The signals from the different elements are made to be in phase by using digital delay lines. The microphone can also be made resistant to turbulences caused by wind by temporarily muting the affected elements, and by surrounding each with a chassis that protects it against wind from a certain direction. The direction would be different for each element.
2010-02-24
A method for training artificial neural networks to generate missing data within a variable context. As the idea is hard to put in a single sentence, I will use an example:
An image may have missing pixels (let’s say, under a smudge). How can one restore the missing pixels, knowing only the surrounding pixels? One approach would be a “generator” neural network that, given the surrounding pixels as input, generates the missing pixels.
But how to train such a network? One can’t expect the network to exactly produce the missing pixels. Imagine, for example, that the missing data is a patch of grass. One could teach the network with a bunch of images of lawns, with portions removed. The teacher knows the data that is missing, and could score the network according to the root mean square difference (RMSD) between the generated patch of grass and the original data. The problem is that if the generator encounters an image that is not part of the training set, it would be impossible for the neural network to put all the leaves, especially in the middle of the patch, in exactly the right places. The lowest RMSD error would probably be achieved by the network filling the middle area of the patch with a solid color that is the average of the color of pixels in typical images of grass. If the network tried to generate grass that looks convincing to a human and as such fulfills its purpose, there would be an unfortunate penalty by the RMSD metric.
My idea is this (see figure below): Train simultaneously with the generator a classifier network that is given, in random or alternating sequence, generated and original data. The classifier then has to guess, in the context of the surrounding image context, whether the input is original (1) or generated (0). The generator network is simultaneously trying to get a high score (1) from the classifier. The outcome, hopefully, is that both networks start out really simple, and progress towards generating and recognizing more and more advanced features, approaching and possibly defeating human’s ability to discern between the generated data and the original. If multiple training samples are considered for each score, then RMSD is the correct error metric to use, as this will encourage the classifier network to output probabilities.
Artificial neural network training setup
2010-02-18
A graphic design methodology that projects a 2D pattern of silhouettes as objects onto a 3D landscape and renders the scene using 3D methods. For example, a set of squares is turned into a city of facades on a landscape, perhaps even with perspective.
2010-01-27
Exact coordinates for computer aided design (CAD). If a CAD program stores coordinates internally as floating point, then movement of objects such as rotations will accumulate error in the inexact numerical coordinates. This could result in two points not coinciding when they should, if they were subjected to different transformations. Perhaps the only way to avoid this would be to store the coordinates exactly, including things like square roots and such in a formula type of an expression. When possible, the expression would be simplified. For example sqrt(2)*sqrt(2) would become 2. The drawback is that everything would become slower.
2010-01-13
Terminator yeast for carbonation of bottled beverages. Carbonation of bottled beverages by yeast has the problem that the yeast will use up all the sugar, and usually it would be good to leave at least some sweetness. So, engineer a yeast that stops fermenting after, let’s say, a number of growth cycles. Additionally, to reduce the amount of sediment, the yeast could be made to waste energy instead of using it for growth. The trigger of this could be related to growth cycles. The best would be detection of pressure, stopping the metabolism of the yeast when there is enough pressure in the bottle. A mechanism for pressure sensing could perhaps be evolved by switching between different food sources and by signaling the switch beforehand by a pressure change. Alternatively the trigger could be CO concentration. Reading a bit on the topic, some researchers have produced cold-sensitive strains of baker’s yeast by using nystatin, which presumably kills growing yeast cells.
2009-10-04
Singing brakes for bicycles. By etching sound wave patterns into the rim, the rim brake could be made to produce tones, maybe even arbitrary sounds.
2009-09-12
Text readable in the order of contraceptive pills
This is intended as an artistic effect, not actual labeling of pills. Uh, sounds like such an obvious idea that someone probably already used it.
2009-08-30
Create genetically manipulated trees with branches in line and only on two sides, to get more knotless lumber
Does the tree twist and loose the polarity? Now this is a possibility.
How to do it? Should look into developmental biology.
Does the tree get enough light? The branches can branch also horizontally so it wouldn’t be just a flat tree. And even if it’s a flat tree it gets about 64 % of the light compared to a normal tree.
Does it replace normal trees in the ecosystem? Unlikely, because it won’t be as effective in collecting light as normal trees.
2007-10-26
A musical wind instrument with electro-acoustic feedback
How is the feedback created? By a microphone and a small loudspeaker.
How does one get different notes? The delay length is adjusted by the player by pressing keys.
How is the feedback delay made? It is either an electronic/digital delay or an array of microphones is used.
What if the speaker is of poor quality? Compensate for example by low-pass filtering. An adjustable filter would also allow coloration of the tone.
OK, I have an idea: A spectrophotometer that can take 2D-images, like a normal camera, but from each pixel you get a complete visible spectrum instead of just red, green, and blue intensities.
Plans for an imaging spectrophotometer
Pictured is one possible way to construct an imaging spectrophotometer. An image of a subject is focused on a slit by a focusing lens so that only a vertical stripe of the subject will be imaged. A collimation lens aligns the paths of light, so that they will land on a diffraction grating at an ideal angle. Different wavelengths are diffracted to different directions, appearing to the camera to be coming from different horizontal angles. Effectively, the camera images the complete visible spectrum of each pixel on the vertical stripe. The spectra do not overlap as they are spread horizontally on the image. The whole system can be rotated horizontally to scan the scene to form a 2D image.
A drawback with this setup is that the camera and rotation must be synchronized as the camera does not know how much the system has been rotated. This is not so easy to do well, unless the scan is made really slow (not a good thing) or the camera is electronically synchronized to rotation (hard to do and possibly expensive). Perhaps something stationary could be made visible in the lower portion of the image, to act as reference.
Masking of stray light was minimal. Also, a reflective slit (a sewing needle) was substituted for the transmissive slit (made of razor blades).
Imaged is a vertical stripe of a fluorescent lamp. The spectrum is shown spread horizontally on the reflective diffraction grating. Because the beams are not collimated, the optimal focusing distance (for the camera) varies by wavelength. Longer wavelengths (red) appear increasingly blurry, as the camera was focused on short (blue) wavelengths. Moreover, the focusing distance that gives the best horizontal resolution deviates increasingly from the vertical one for increasing wavelengths. Such optical anisotropy should also be eliminated by collimation, but at the probable cost of vignetting. Another benefit of collimation is that imperfections of the grating will be out of focus.
For parts, I bought an old Zenit EM film SLR camera from my friend for 20 EUR to obtain both the focusing lens (Helios 44M 58 mm f 1:2) and a fixture for it (the camera body). This lens has some desirable properties: manual focus and manual aperture. The diffraction grating is very large, about 8 cm x 8 cm, scavenged from some sort of a spectrophotometer, at no cost. I’m buying two more of the Zenit cameras, at ebay.co.uk, in hopes that having identical lenses simplifies the design.
2009/07/27
A gutted Russian Zenit EM camera body
I bought a total of three of these. Each came with a Helios-44M 2/58 kit lens and cost at most 20 EUR a piece, including postage. The razor blade slit will rest on top of the inner film guides (the inner ones of the four bright lines), against which the film normally rests. The outer guides must go as they would otherwise lift the blades off the focusing plane.
Outer film guides filed down
Filing the aluminum body was easy. The inner guides were protected by multiple layers of masking tape.
Another Zenit EM, with the rear side sawed off
This drastic operation creates some space for the focusing plate from the other camera body.
Two camera bodies mated, the other upside down
The camera bodies were mated using two wooden blocks and 8 screws, and a few spacers to correct for any inclination. The important thing is for the two lenses to share the same optical axis, and that they both draw the image on the slit (not yet installed in this picture) when focused to infinity.
The razor blade slit viewed from outside
The razor blade slit viewed from inside
Reinforcement bars keep the blades straight. Without them, the blades are too flexible and curve easily, making the effective width of the slit more dependent on viewing angle.
The width of the slit was adjusted manually while the glue was solidifying. Super glue is no good for this as it solidifies instantly.
2009/07/29
First test with collimated optics
Looks promising! The image is quite sharp in both directions, and spectral resolution is awesome. Now need to worry about vignetting (darkening of the image toward corners).
Getting there... using a 300 grooves/mm grating
This time using three Helios-44M 2/58 lenses, including one for the Canon EOS 450D camera. There’s perhaps something to matched optics. The image has not even been cropped. Also, another diffraction grating is in use. Two diffraction orders are visible, and a bit of ultraviolet light from a third one. The diffraction grating is “blazed” to concentrate transmittance on the shown run of bands. That’s why there are no blue bands visible on the left.
Imaged is a circuit board from a dismantled spectrophotometer. :-) The light is from a fluorescent lamp, hence the discontinuous spectrum.
Vertical resolution is satisfyingly good. The slit is perhaps too wide; some horizontal features of the imaged object are visible (not at the low resolution of this web image), especially at the narrow ultraviolet band. But this is good enough for now.
2009/07/30
Now using a 1200 grooves/mm grating
The 1200 grooves/mm grating gives better spectral resolution than the 300 grooves/mm grating in the earlier picture. But also, there is not much headroom for wavelengths outside red and violet in case I get a camera that can capture a wider range of wavelengths than is visible to humans. It is possible to modify the Canon EOS 450D by removing a filter inside it, but I’m a bit scared of the process. I won’t consider it before this thing is working.
These kind of gratings cost around 100 EUR a piece new, but mine were scavenged from spectrophotometers thrown away by the chemistry department, so, free.
The continuous stripe of spectrum is from the flame of a Colt cigarette lighter. :-) The background is the usual circuit board illuminated by a fluorescent lamp. There’s some ghosting in the upper left corner, probably because of reflections inside the lenses. The flame was quite bright.
Smack together the spectrum to see what's on the slit
What the objective lens drew on the slit can later be recomposed from the spectrum. The process is illustrated. All wavelengths are simply squeezed back together. (It looks black and white, but it’s the fault of jpeg image compression)
2009/09/11
The system as it currently is, constructed on a turntable plate
Before operation, the optics are covered with pieces of black leather.
The resulting image of the first manual scanning test.
The resulting image of the first manual scanning test. The actual scan:
The video was recorded while the system was manually rotated counterclockwise. So in fact this video encodes a complete image! Points to anyone who can tell what the scene is (Joonas got some points for this!). The original resolution of each video frame from Canon EOS 450D was 848 x 560. The final vertical resolution is thus 560 pixels. With a more coarse diffraction grating, it would be possible to rotate the camera 90 degrees to get a vertical resolution of 848 pixels. The borders are just for contrast.
The image file encoding gamma 1/2.2 was taken into account. Basically, before doing arithmetic on pixel RGB values as if they were proportional to luminous intensity, they were raised to power 2.2. And before the results were written back into an image file, the inverse operation, power 1/2.2, was employed.
Still tons of things to improve in how the image is generated, but it’s a good start. List of things to do:
Correct optical distortion by postprocessing to reduce color bleeding.
Figure out where each wavelength is.
Take into account Canon EOS 450D RGB sensor sensitivity curves to improve dynamic range of pixels that have some of the color channels saturated.
Replace the Canon sensor RGB sensitivity curves with CIE 1931 XYZ color matching functions to better model human color vision. (Canon ain’t perfect!)
2009/08/12
Saturation at the Canon EOS 450D sensor
A lot of extra dynamic range could be mined from this. But it needs a bit of detective work. The color space is sRGB, which is not directly the raw sensor data, but something like a linear combination including negative coefficients.
2009/08/13
Fraunhofer lines of sunlight
Fraunhofer lines can be used for wavelength calibration. This image is for demonstration, not an actual calibration. Sandwiched is the measured spectrum of the evening sun, cut in two to increase detail in the web image. Some major and some minor Fraunhofer lines are visible.
G, 430.8 nm, iron and calcium
F, 486.1 nm, helium
b4, 516.9 nm, iron
E, 527.0 nm, iron
D3, 587.6 nm, helium
a, 627.7 nm, atmospheric oxygen
C, 656.3 nm, hydrogen
There are many additional lines visible, some stronger than some of the designated ones.
Fraunhofer lines are due to absorption of light by elements in sun’s outer layer and by oxygen in Earth’s atmosphere.
2009/08/16
Correction of the spectrum image geometry
The spectrum image geometry was corrected by manually adjusting a 3×3 grid of control points and by biquadratic interpolation of the coordinates of the control points in the source image. The basis functions used were:
Bicubic Catmull-Rom interpolation (at gamma 1.0, of course) was used for reading the source spectrum image.
For the calibration, imaged was a black metal grid against sunlight. This provided both horizontal (metal grid) and vertical (Fraunhofer) lines that were then made straight by adjusting the control points.
The bottom row shows the resulting enhancement for the first manual scan test. Vertical color fringing is reduced.
Some types of distortion cannot be corrected by a 3×3 grid of control points, for example bulging that makes the image more dense toward the edges. So, I derived piece-wise quadratic basis functions for 4 control points. I might implement them later. Here goes:
Because the sensitivity curves of the Canon sensors were unknown, the readings needed to be normalized against a light source of a known spectrum. The emission spectrum of an incandescent lamp is very close to black-body radiation, which is well characterized theoretically. I happened to have a 10.8 V 30 W halogen bulb from a spectrophotometer, unfortunately of unknown color temperature. But it was possible to measure the color temperature against the white balance settings of Canon EOS 450D. I hooked the lamp to a 12 V power supply and filtered the power further by a large capacitor (on the right in the picture). I allowed the lamp to heat up for a few minutes and took a picture of it without a lens using the incandescent white balance setting, “approximately 3200 K”, as reported by Canon. The picture was basically a gray rectangle.
The average color in the rectangle was sRGB 152, 144, 143. In linear sRGB (gamma 1.0), this is 0.3140, 0.2789, 0.2747. The CIE1931 xy hue for 3200 K black-body radiation is 0.4234, 0.3990, which is equivalent to linear sRGB 0.6703, 0.3456, 0.1299. That multiplied with the lamp’s linear sRGB color gives the color of the lamp using the correct sRGB reference white point of 6500 K. The result is in linear sRGB 0.2105, 0.09637, 0.03567, or in xy 0.4352, 0.3962. This does not correspond exactly to black-body radiation at any temperature, but comes closest to 3100 K, for which xy is 0.4300, 0.4016.
To summarize, it could now be presumed that the lamp emits black-body radiation at temperature 3100 K, or 2800 °C for those who wonder.
2009/08/21
I found the specificationss of the lamp, and surprise, surprise, a color temperature of 3100 K was cited. :) I’m using a somewhat higher voltage, 12 V instead of the specified 10.8 V, so the true color temperature will be somewhat higher.
2009/08/24
Motor and parts for transmission
To rotate the spectrophotometer I needed a really slow-revolving motor. I was first thinking of stepper motors, but digging into my piles of stored junk I found four Maxon DC motors (about 12 V) with 5:1 gearheads. Better yet, the gearheads could be detached from the motors and, put in a suitable configuration, chained. Four gearheads in a chain gives a total gear ratio of 625:1.
Tooling and a failed attempt at making the gearbox case
I drilled flat-bottom slots for the gearheads into 2-by-4 lumber. A couple of attempts failed because some of the slots turned out slightly misaligned.
My plans were: Slot diameter is 35 mm. The depth of the first slot (the one with the motor) is 14 mm. Successive slots ascend 6 mm per slot. The slot chain turns 60° counterclockwise at each slot, successive slots being separated by 30.5 mm center-to-center. Gearhead output shaft hole diameter is 12 mm and is 7 mm off the slot axis, oriented straight towards the next slot in the chain.
Motor and transmission, this time working!
Following my original plans, the distance between gearheads had to be accurate down to about 0.3 mm. This was hard to achieve. As a trick to get around this problem, positioning errors were compensated for by rotating the gearheads and by changing the chain turning angle accordingly. A slot was drilled for just one gearhead at a time, the gearhead was rotated in the slot until the gear teeth meshed correctly with the previous gearhead, and the chain was continued to the direction pointed to by the orientation of the gearhead. Done this way, and with a bit of luck with the holes for the gearhead output shafts, everything worked on first go.
The gearbox was later sawed off, sanded slightly, cleaned and spray-painted to fixate wood dust and splinters to keep the gears clean.
Flip side of the gearbox
The belt drive will further increase the gear ratio from 625:1.
2008/08/25
Running the motor at 12 V, I clocked 1 min 18 s per revolution of the transmission output shaft. For the motor, that is 8 revolutions per second, 480 rpm.
2008/08/26
A change in plans, a roller instead of belt drive
I tried the belt drive mechanism but it resulted in jerky motion. This is my theory why: Slow rotation combined with the elastic rubber belt and friction of the turntable plate shaft allows the plate rotation to halt repeatedly. During such a halt, tension of the belt builds up until it is stronger than the static friction of the plate shaft, yanking the plate back into rotation. The rotation speed of the plate temporarily exceeds its average rotation speed, causing the belt to loosen. This gives another opportunity for a halt. There wasn’t much to do to reduce plate shaft friction. I tried oiling it, helped none.
There was so much weight on the plate that significant friction resulted in any case. So, something had to be done to the elasticity of the rubber belt. The solution was a roller mechanism. The belt was removed, and an O-ring was slipped around the gearbox output pulley which was then pressed against the turntable plate pulley (the shiny, curved metal strip in the image). This resulted in smooth and steady rotation of the turntable plate.
A support case made out of two pieces of 2-by-4 lumber. Gearbox on the right.
Inside the case there is a cavity that contains 3 x 3.7 V lithium ion cells in series totaling 11.1 V. The case has a 12 V DC power input and a switch that enables the batteries for charging or for use. I don’t know how smart that was; now the motor will be running when batteries are charging. Perhaps the sound is a good reminder not to forget to disconnect power
On the gearbox, there is a switch for changing the direction of rotation. The motor can actually be disconnected by setting this switch in the middle position. The switch does not lock in the middle position, so that way of stopping the motor is a bit cumbersome and unreliable. The batteries will rarely need charging, so perhaps I won’t add an extra switch for turning off the motor.
A furniture hinge with a spring connects to the gearbox. The spring ensures that the roller is pressed with enough pressure against the turntable plate pulley. The plate is not installed in this picture.
Running on batteries, I measured one complete turn of the turntable plate taking 8 min 59 s. Given the Canon EOS 450D frame rate of about 20.7 frames per second (using the longest exposure), one gets about 11000 pixels per rotation. For comparison, a 50 mm focal length lens, which is often said to give a natural viewing angle, gives a horizontal viewing angle of 39.6° on a 35 mm camera body. This system would have a scanned horizontal resolution of about 1200 pixels for that viewing angle. Sounds good to me.
The motor and batteries do not heat noticeably even if the motor is left running for a long time. Guess the motor does not need to generate much torque. Even with the turntable plate installed, the motor was running happily on batteries for 5 hours, or until I stopped the test.
The system set up on a camera stand
Each Zenit EM camera came with a case, each of which had a metal part with the standard thread for connecting to a camera stand. One such part was embedded and immobilized into the bottom of the support case, in line with the turntable shaft.
2009/08/28
Resulting image of a motorized scanning test
With motorized scanning, horizontal resolution is at least on par with vertical resolution. This image is at the original resolution.
One worrisome thing is that sensor noise is starting to be visible if gain is increased any further. This applies when there is not enough light, like on a cloudy day as in this picture. Most of the noise appears on the red channel. Here in Finland, it is getting darker and darker as we go further into autumn, so I’m afraid I won’t get much outdoor images in near future.
A good thing is that as the rotation is so smooth, there is no need to synchronize the camera to rotation. Frame dropouts are still possible though.