robot36 - encode and decode images using SSTV in Robot 36 mode
 
 
Go to file
Ahmet Inan 5860ded471 use revised value K0 for SRGB 2021-04-16 17:53:43 +02:00
.gitignore also .gitignore generated gnuplot files 2011-10-29 10:51:03 +02:00
COPYING changed license to CC0 2011-09-08 16:16:27 +02:00
Makefile fixed compilation for some distributions 2015-01-19 11:20:01 +01:00
README updated image links 2015-01-20 20:03:21 +01:00
alsa.c rearranged and fixed alsa init code 2015-02-23 13:30:16 +01:00
alsa.h dont hide structs behind typedefs 2012-06-01 23:41:04 +02:00
buffer.c oops: return pointer to last element, not to next 2012-09-18 23:07:06 +02:00
buffer.h redesigned ddc, replaced delay lines with common buffer 2012-09-14 22:05:41 +02:00
ddc.c normalize phasor after each step 2014-11-26 13:06:29 +01:00
ddc.h redesigned ddc, replaced delay lines with common buffer 2012-09-14 22:05:41 +02:00
debug.c removed unused y_pixel_x and uv_pixel_x 2013-12-15 14:50:01 +01:00
decode.c do lerp of Y' in linear space. 2014-11-10 10:15:28 +01:00
encode.c renamed linear_srgb to srgb and srgb_linear to linear 2014-01-28 09:17:06 +01:00
img.c dont hide structs behind typedefs 2012-06-01 23:41:04 +02:00
img.h dont hide structs behind typedefs 2012-06-01 23:41:04 +02:00
mmap_file.c removed extra white space 2012-09-30 18:53:37 +02:00
mmap_file.h changed license to CC0 2011-09-08 16:16:27 +02:00
pcm.c dont hide structs behind typedefs 2012-06-01 23:41:04 +02:00
pcm.h dont hide structs behind typedefs 2012-06-01 23:41:04 +02:00
ppm.c dont hide structs behind typedefs 2012-06-01 23:41:04 +02:00
ppm.h dont hide structs behind typedefs 2012-06-01 23:41:04 +02:00
sdl.c dont hide structs behind typedefs 2012-06-01 23:41:04 +02:00
sdl.h dont hide structs behind typedefs 2012-06-01 23:41:04 +02:00
smpte.ppm remade smpte.ppm again: sharp edges this time. 2013-09-02 16:42:26 +02:00
utils.h make lerp more stable 2012-10-22 19:38:51 +02:00
wav.c dont hide structs behind typedefs 2012-06-01 23:41:04 +02:00
wav.h dont hide structs behind typedefs 2012-06-01 23:41:04 +02:00
window.c changed license to CC0 2011-09-08 16:16:27 +02:00
window.h changed license to CC0 2011-09-08 16:16:27 +02:00
yuv.c use revised value K0 for SRGB 2021-04-16 17:53:43 +02:00
yuv.h renamed linear_srgb to srgb and srgb_linear to linear 2014-01-28 09:17:06 +01:00

README

robot36 - encode and decode images using SSTV in Robot 36 mode
Written in 2011 by <Ahmet Inan> <xdsopl@googlemail.com>
To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.
You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.

robot36 is written from scratch just for the fun of it.
i have no ham radio and started this project out of curiosity how people are able to encode or decode FM in very good quality just using an DSP with DAC or ADC.

Theory of operation:
Robot 36 is one mode of many SSTV modes which transfers images using the luminance / chrominance information of the image.
Like with other SSTV modes, the information is send using FM and needs only 800hz bandwidth for data (1500hz-2300hz) and 200hz for control (1100hz-1300hz).
Robot 36 transfers 320x240 color images in around 36 seconds, hence the name Robot 36.
More information about Robot 36 mode and SSTV can be found on the Internet.
I suggest finding and reading the wonderful "Dayton Paper" of JL Barber (N7CXI).

encode:
Here we simply change the rate of an complex oscillator according to the Y, U and V values we get from the input image and only use the real part of the oscillator as output.

decode:
FM demodulation is not so easy. After many frustrating attempts to emulate hardware and playing around with zero cross detection and Phase-locked loop detectors i finally found a very nice way to do it:
Using Hilbert Transformation we get a complex valued function from a real valued function, which we differentiate in time using polar coordinates and getting the instantaneous frequency from the argument.
Doing Hilbert Transform in discrete space for this purpose is also know as Digital Down Conversion.
my DDC consists of an complex valued decimating ideal fir filter using Kaiser window at its input and an complex oscillator mixer at its output.
You can find a lot more about DDC's and FM demodulation on the Internet.
I Suggest finding and reading the enlightening "Virtual Radios" Paper of Vanu Bose, Michael Ismert, Matt Welborn, and John Guttag.
You should also look at GNU Radio: http://gnuradio.org/ and at the invaluable information at dspGuru: http://www.dspguru.com/

smpte.ppm is converted from http://en.wikipedia.org/wiki/File:SMPTE_Color_Bars.svg

compile everything:
# make

test encode and decode using smpte.ppm and various rates:
# make test

remove generated files:
# make clean

listen to default alsa device and write out ppm images with %F-%T.ppm as file name:
# ./decode

listen to alsa device plughw:0,0 and write out ppm images with %F-%T.ppm as file name:
# ./decode plughw:0,0

listen to default alsa device and show image in sdl window:
# ./decode default sdl:

read from wav file input.wav and write out to ppm image output.ppm:
# ./decode input.wav output.ppm

encode ppm image input.ppm to output.wav using rate of 40000Hz
# ./encode input.ppm output.wav 40000

encode ppm image input.ppm and write out to default alsa device
# ./encode input.ppm

last but not least, have fun with a debugging session:
# make fun

now ppm files have debugging pixels and show raw data like this:
https://sites.google.com/site/xdsopl/home/robot36_raw_image.png

you can look at the signal analysis using gnuplot:
# gnuplot
gnuplot> load "8000.gnu"

this should give you an output like this:
https://sites.google.com/site/xdsopl/home/robot36_signal_analysis.png