Adventures in 3D. pt1

April 10th, 2011

Since 3D is ‘here to stay’ (again), I thought I’d look into some things, like how to make pictures or movies, process them, watch them, generate them without any special 3D screen or graphics board.
I got me a Fujifilm Finepix Real 3D W3 camera…:

… and started messing around.

The camera has a fixed interocular distance (or baseline) of 75mm, which is about 10mm more than the average distance between the human eyes. Convergence is not possible, the lenses are parallel, looking at infinity.
It can shoot 3d stills, and 720p 3d movies. It is possible to experiment with more or less interocular distance and convergence by using the option to shoot the left/right image separately. The camera then shows the left picture with 50% opacity on the screen which allows you to line up the right picture and complete the stereo-pair.
The camera has a lenticular, autostereoscopic screen allowing you to view the 3D effect in real-time without glasses.
Here are some pictures taken with the W3:

The pictures are recorded in .MPO format, which is basically 2 JPG images in 1 file. The images can be viewed using StereoSplicer, a simple yet very handy free application which allows you to export the .MPO as a stereopair, anaglyph and parallel or cross-eyed side-by-side image.


StereoSplicer
(OS X)

The movies can be saved as left and right, also using StereoSplicer, or can be viewed using Bino, which supports a wide variety of in- and output formats.

Morbus

January 31st, 2011

Made entirely in jitter with jit.bfg and morphing/fading between different instances of jit.bfg (basic function generator).
Everything was captured in real-time using a Matrox MXO box

In Retrospect #1

January 30th, 2011

Two stills from the live accompaniment of Byron Wallen on the first edition Motives Jazz Festival in Genk in 2004.
Unfortunately that’s about all that remains from that show, but then a again, live cinema or visual music is something you have to experience live.


ASCII Game of Life

October 28th, 2010

An ASCII version of Conway’s ‘Game of Life’, made in C. The code is below, you can compile your own version using Xcode or gcc in the terminal. I don’t know how it behaves in windows, especially the system(“clear”);  call is probably not something which works on every platform… Let me know how it behaves if you’ve tried it.

#include <stdio.h> //standard input/output
#include <stdlib.h> // for the rand() and srand() function
#include <time.h> // for seeding the rand() function with time()
#include <unistd.h> //for the sleep function
#include <math.h> // for the square root function

int i, j, k, telOp;
int arraySize, iterations;
int square[50][50];
int squareTemp[50][50];
void initRand()
{
    srand((unsigned)(time(0)));
}

void createMap(){
        for (i = 0; i < arraySize; i++) {
                for (j = 0; j < arraySize; j++) {
                        square[i][j] = rand()%2;
                        squareTemp[i][j] = 0;
                        //**print coordinates**//
                        //printf("%i, %i\n", i, j);
                }
        }
}

void checkMap(){
        int iMin,iPlus,jMin,jPlus;
       
        for (i = 0; i < arraySize; i++) {
                for (j = 0; j < arraySize; j++) {
                        if (i == 0){ iMin = arraySize; } else {iMin = i-1;}
                        if (i == arraySize){ iPlus = 0;} else {iPlus = i+1;}
                        if (j == 0){ jMin = arraySize; } else {jMin = j-1;}
                        if (j == arraySize){ jPlus = 0;} else {jPlus = j+1;}

                                telOp =  square[iMin][jMin]+
                                                 square[i][jMin]+
                                                 square[iPlus][jMin]+
                                                 square[iMin][j]+
                                                 square[iPlus][j]+
                                                 square[iMin][jPlus]+
                                                 square[i][jPlus]+
                                                 square[iPlus][jPlus];
                                if (telOp < 2){
                                        squareTemp[i][j] = 0;
                                }
                                else if (telOp > 3){
                                        squareTemp[i][j] = 0;
                                }
                                else if (telOp == 3){
                                        squareTemp[i][j] = 1;
                                }
                                else if (telOp == 2){
                                        squareTemp[i][j] = square[i][j];
                                }
                                //printf("telop = %i\n", telOp);

                        }

                }
       
        for (i = 0; i < arraySize; i++) {
                for (j = 0; j < arraySize; j++) {
                        square[i][j] = squareTemp[i][j];
                }
        }
}      

void printMap(){
        system("clear");
       
        for (i = 0; i < arraySize; i++) {
                for (j = 0; j < arraySize; j++) {
                        if (square[i][j] == 0) {
                                printf("..");}
                        else {
                                printf("[]");
                        }

                }
                printf("\n");
        }
}

int main (int argc, const char * argv[]) {
    // insert code here…
        //Initialize the map
        printf("What grid size would you like? (1 – 50): ");
        scanf("%i", &arraySize);
        printf("How many iterations would you like? ");
        scanf("%i", &iterations);
        if (arraySize <= 50 && arraySize > 0) {
                initRand();
                createMap();
               
                for (k = 0; k < iterations; k++) {
                        checkMap();
                        printMap();
                        usleep(20000);
                }
               
        }
               
        //printf("%i",sizeof(square) / sizeof(int));
        return 0;
}

Elementary Cellular Automata for the Terminal

October 28th, 2010

I’ve been learning C for the last 2 weeks and while I’m still making ‘command line tools’ in Xcode, I figured that’s no reason not to have ’graphics’.

Why not make ASCII versions of some interesting processes. So behold! The elementary cellular automata as described on the Wolfram Mathworld site.

The code:

#include <stdio.h>
#include <unistd.h> //for the sleep function
#include "dec2bin.h" //function to get the binary equivalent of the rule
#include <string.h> //for the string comparison

int decimal;
char binary[9];
char neighbors[4];
char bin1[4] = "111";
char bin2[4] = "110";
char bin3[4] = "101";
char bin4[4] = "100";
char bin5[4] = "011";
char bin6[4] = "010";
char bin7[4] = "001";
char bin8[4] = "000";
char singleLine[31], lineTemp[31];
int i, j, iMin, iPlus, stringTest;
void applyRules();

/****************************************************************/
//Function to initiate the line to all 0, except the center one
/****************************************************************/

void initLine(){
        for (i = 0; i < 31; i++) {
                singleLine[i] = ’0′;
                lineTemp[i] = ’0′;
        }
        singleLine[15] = ’1′;
        lineTemp[15] = ’1′;
}

/****************************************************************/
//Function to print the line
/****************************************************************/

void printLine(){
        for (i = 0; i < 31; i++) {
                if (singleLine[i] == ’0′) {
                        printf("__");
                }
                else if (singleLine[i] == ’1′){
                        printf("[]");
                }
                                 }
        printf("\n");
        applyRules();
}
/****************************************************************/
//Function to apply the rules
/****************************************************************/

void applyRules(){
        for (i = 0; i < 31; i++) {
               
                if (i == 0){
                        iMin = 30;
                        iPlus = i+1;
                }
                if (i == 30){
                        iPlus = 0;
                        iMin = i-1;
                }
                else if (i != 0 && i != 30) {
                        iMin = i-1;
                        iPlus = i+1;
                }
                neighbors[0] = singleLine[iMin];
                neighbors[1] = singleLine[i];
                neighbors[2] = singleLine[iPlus];

                        if (strcmp(neighbors, bin1) == 0){
                                lineTemp[i] = binary[0];
                        }
                        else if (strcmp(neighbors, bin2) == 0){
                                lineTemp[i] = binary[1];
                        }
                        else if (strcmp(neighbors, bin3) == 0){
                                lineTemp[i] = binary[2];
                        }
                        else if (strcmp(neighbors, bin4) == 0){
                                lineTemp[i] = binary[3];
                        }
                        else if (strcmp(neighbors, bin5) == 0){
                                lineTemp[i] = binary[4];
                        }
                        else if (strcmp(neighbors, bin6) == 0){
                                lineTemp[i] = binary[5];
                        }
                        else if (strcmp(neighbors, bin7) == 0){
                                lineTemp[i] = binary[6];
                        }
                        else if (strcmp(neighbors, bin8) == 0){
                                lineTemp[i] = binary[7];
                        }

                }
        for (j = 0; j < 31; j++) {
                singleLine[j] = lineTemp[j];
        }
        usleep(50000);
        printLine();
}
/****************************************************************/
/****************************************************************/

int main (int argc, const char * argv[]) {
        initLine();
        printf("Which rule to use (0 – 255)?\n");
        scanf("%i", &decimal);
        dec2bin(decimal, binary);
        printf("\n The binary value of %i is %s \n",decimal,binary);
        printLine();
        return 0;
}

and the required library :

void dec2bin(int decimal, char *binary)
{
        int  k = 0, n = 0;
        int  remain;
        char temp[9];
       
        // if the input is wrong, abort and give error message
        if (decimal < 0 || decimal > 256)
        {  
                printf("error: rule # must be between 0 and 255)\n");
                return;
        }
       
        do
        {
                remain    = decimal % 2;
                decimal   = decimal / 2;
                temp[k++] = remain + ’0′;
        } while (k < 8);
       
               
        // reverse the spelling
        while (k >= 0)
                binary[n++] = temp[k];
       
        binary[n-1] = 0;
}

New Comments

New Articles

Random Articles