r_adjust_opc.m 1.74 KB
function r_adjust_opc(expNumber,zone,iFirst,iEnd,gamma)
% R_ADJUST_OPC - It is specifically adapted to
% images taken from the Observatoire du Pic Champlain (OPC)
% 
% Syntax:  r_adjust_opc(expNumber,zone,iFirst,iEnd,gamma)
% 
% Inputs:
%    expNumber - The date number (yyyymmdd). Points to a directory
%    zone      - The part of the scene to analyse. See the code for details
%    iFirst    - The first image to be treated
%    iEnd      - The last image to be treated
%                (if iEnd is set to zero, the loop is done from iFirst to
%                 nFiles)
%    gamma     - gamma adjustement
% 
% Example:
%    r_adjust_opc(20140203,3,1,0,1)
% 
% Other m-files required: g_rect toolbox
%   (http://demeter.uqar.ca/g_rect)
% Subfunctions: none
% 
% See also: G_RECT, R_UNDISTORT, R_ROTATE, R_INTERP_OPC

% Author: Dany Dumont
% UQAR/ISMER
% email: dany_dumont@uqar.ca
% Website: http://www.ismer.ca/dumont-dany
% February 2014
% ______________________________________________________________________

estr = num2str(expNumber);
zstr = num2str(zone);
gstr = num2str(gamma);

rootdir = '/Volumes/DyDisk/data/opc/images/2014';
expdir  = [rootdir,'/',estr];
origdir = [expdir,'/original'];
intdir  = [expdir,'/interp'];
zonedir = [intdir,'/zone',zstr];
adjustdir = [zonedir,'/adjust'];

cd(zonedir)

imfiles = dir('*.jpg');
nFiles  = size(imfiles,1);

if iEnd == 0
    iEnd = nFiles;
end

if ~exist(adjustdir,'dir')
    mkdir(adjustdir)
end

for n = iFirst:iEnd
    
    imfilename = imfiles(n).name;
    imNumber   = imfilename(1:17);
    
    I0 = imread(imfilename);
    
    maxval = max(max(double(I0)))./255;
    
    I = imadjust(I0,[0.5 maxval-0.03],[],gamma);
    
    imwrite(I,[adjustdir,'/',imNumber,'_adjust.jpg'],'jpg');
    
    disp([' ',imNumber]);
    
end