Welcome to Fractal Forums

Fractal Software => General Discussion => Topic started by: quaternion on August 26, 2010, 11:34:41 PM




Title: Holograms.
Post by: quaternion on August 26, 2010, 11:34:41 PM
I found this software: http://www.corticalcafe.com/prog_CGHmaker.htm, kan i use halogen or led lamp?


Title: Re: Holograms.
Post by: Schlega on August 27, 2010, 09:44:50 AM
It sounds like that program's outpput depends on usinng a lazer source, but it is possible to make holograms that work in any light. It is even possible to draw them by hand. (http://amasci.com/amateur/holo1.html)


Title: Re: Holograms.
Post by: quaternion on August 27, 2010, 05:39:34 PM
I think I must use lens for light point.

P.S. I found simplest example for holograms creation.

Code:
//holo.c--simple program for computer-generated holography
//Thad G. Walker University of Wisconsin-Madison
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include "nrutil.h" //Numerical Recipes routines for memory allocation
#define twopi 6.283185307
#define R 75
//Resolving power of hologram
#define N 300
//hologram width in pixels
#define thres 0.6
//threshold for binary approximation
void main(){
char pixel,obj;
int X,Y,row,col,junk;
float **pix,kdf=twopi/2.0,ranphi,max=0.0,min=0.0,res=R;
FILE *out,*in;
out=fopen("holo.pgm","w");
// output file, N X N size graphics file
in=fopen("uwphysics.pgm","r"); //input file, R X R size graphics file
fprintf(out,"P5 %d %d 255\n",N,N);//header
fscanf(in,"%1s %1s %d %d %d",&junk,&junk,&junk,&junk,&junk);//header
srand(17);
//seed random number generator
pix=matrix(0,N-1,0,N-1);
//allocate memory for graphical output
for(X=0;X<N;X++){for(Y=0;Y<N;Y++){pix[X][Y]=0.0;}}
//initialization
//construct real hologram from input image
for(row=0;row<R;row++){for(col=0;col<R;col++){
fscanf(in,"%1c",&obj);
//read 1 byte at a time
if(obj!=0){
//all non-zero bytes given same intensity
ranphi=((float) rand())/((float) RAND_MAX)*twopi;
//select random phase
for(X=0;X<N;X++){for(Y=0;Y<N;Y++){
pix[X][Y]+=cos(kdf*(X*(1.-row/res)+Y*col/res)+ranphi);//add to hologram
}}
}
}}
//find max min
for(X=0;X<N;X++){for(Y=0;Y<N;Y++){
if(pix[X][Y]>max)max=pix[X][Y];
if(pix[X][Y]<min)min=pix[X][Y];
}}
//print output file
for(X=0;X<N;X++){for(Y=0;Y<N;Y++){
if((pix[X][Y]-min)/(max-min)>thres){pixel=255;
}else{pixel=0;}
fprintf(out,"%c",pixel);
}}
}