clear all
close all

% Third Image (without flash)
A3=imread('images/990302-012.bmp','bmp');

B3_1=A3(401:800,26:75);
B3_2=A3(401:800,131:180);
B3_3=A3(401:800,251:300);
B3_4=A3(401:800,371:420);
B3_5=A3(401:800,476:525);
B3_6=A3(401:800,601:650);
B3_7=A3(401:800,711:760);
B3_8=A3(401:800,826:875);
B3_9=A3(401:800,951:1000);
B3_10=A3(401:800,1061:1110);

C3_1=double(B3_1)./255;
C3_2=double(B3_2)./255;
C3_3=double(B3_3)./255;
C3_4=double(B3_4)./255;
C3_5=double(B3_5)./255;
C3_6=double(B3_6)./255;
C3_7=double(B3_7)./255;
C3_8=double(B3_8)./255;
C3_9=double(B3_9)./255;
C3_10=double(B3_10)./255;

m(1) = mean(mean(C3_1));
m(2) = mean(mean(C3_2));
m(3) = mean(mean(C3_3));
m(4) = mean(mean(C3_4));
m(5) = mean(mean(C3_5));
m(6) = mean(mean(C3_6));
m(7) = mean(mean(C3_7));
m(8) = mean(mean(C3_8));
m(9) = mean(mean(C3_9));
m(10) = mean(mean(C3_10));

x=1:-0.1:0.1;
plot(x,m,'b+--');
grid on;
gamma=polyfit(log(m),log(x),1);
l=0:0.1:1;
y=l.^gamma(1);
hold on
plot(y,l,'ks-');
legend('Actual Data', 'Estimated Data', 2)
title('Curve Fitting for Camera Gamma Estimation')
xlabel('Linear Values')
ylabel('Gamma Corrected Values')
hold off

