% image_adjust is a program that allows images % such as 'jpg', 'gif', 'bmp' etc to be adjusted % in terms of numerical data. % Adjustment is done by either increaseing the % green and blue components by addition, or by % exponential compression. % USE: Change the file name, type, folder below % to the images you are interested in working on. % % run image_adjust % % Last Edit by Colin Joye, 10/2/03 clear all; %-------------- USER INPUT ----------------------- % location of folder. =[] is \work folder. %folder = 'C:\Documents and Settings\Colin Joye\My Documents\AES_115th\images\'; folder = 'C:\Documents and Settings\Colin Joye\Desktop\'; % file type can be 'jpg', 'gif', 'tiff', 'bmp', etc. file_type = 'jpg'; % name of current file to be modified. in_file_name = 'photo5'; % name of new adjusted file to be saved. out_file_name = 'photo5_adj'; % Red, Green and Blue level adjust: adds number specified to numerical % image data, which ranges from 0 to 255 in integers. red = -20; grn = -20; blu = -20; % COMP factor introduces compression to the image by raising the data to % an exponential factor. comp==1.0 means no compression. Using a little % compression tends to remove haze from the image and increase contrast. comp = 1.02; % Image rotation angle to correct tilted images [degrees CCW] phi = 0; %-------------- END USER INPUT ----------------------- A = imread([folder in_file_name],file_type); % read image, store as "uint8" type B = double(A); % convert "uint8" to "double" for math [Lr Lc Lz] = size(B); base = ones(Lr, Lc); adj = cat(3, red*base, grn*base, blu*base); % Color adjust method: C = B.^comp + adj; % BW high contrast method: %C = 220*(B>233)+35; % rotate image: C = imrotate(C,phi,'bilinear','crop'); D = uint8(C); % convert back to "uint8" to save imwrite(D,[folder out_file_name '.' file_type],file_type); % save with new filename % show the change: figure(1) clf(1) subplot(121) image(A); axis image; title(['Original: ' in_file_name '.' file_type],'Interpreter','none'); subplot(122) image(D); axis image; title(['Altered: ' out_file_name '.' file_type],'Interpreter','none'); % ------------------ END image_adjust.m ----------------------------