
gamma = 160;

gray = ones(100, 200);

gray(:,:) = gamma/255;

gray(:,100:200) = 0;
gray(1:2:100,100:2:200) = 1;
gray(2:2:100,101:2:200) = 1;


[X map] = rgb2ind(gray, gray, gray, 256);
imshow(X, map), axis equal;
imwrite(X, map, 'gamma.bmp', 'bmp')

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

load /local/class/psych221/tutorials/cMatch/monitorGam
figure;
plot(1:256,monitorGam(:,1)), grid on
xlabel('Frame buffer'); 
ylabel('Emitted intensity of red phoshor');
title('Display "Gamma" function')

frameBuffer = 1:256;
pred = ((frameBuffer)/256).^(1.495);
plot(frameBuffer,pred,'b-',frameBuffer,monitorGam(:,1),'r-')
grid on

pred(160+1)
