Code covered by the BSD License  

Highlights from
deprecated -- Light Field Toolbox v0.2 -- v0.3 now available

image thumbnail

deprecated -- Light Field Toolbox v0.2 -- v0.3 now available

by

 

26 Apr 2013 (Updated )

A set of tools for working with light field (aka plenoptic) imagery in Matlab

adaptimadj(img,win,th)
function imgout=adaptimadj(img,win,th)
% ADAPTIMADJ adaptively adjusts the intensity of an image

% ADAPTIMADJ adaptively adjusts the intensity of the input image. The
% adjustment is performed according to the mean and standard deviation of
% the region around each pixel.
% 
% USAGE:
%     imgout=adaptimadj(img); default window size is min(size(img))/5,
%     default th is 1.
% 
% INPUTS:
%     img: grayscale double image
% 
%     win: size of the rectangular region to inspect at each pixel
% 
%     th: parameters that tunes the degree of adjustment
% 
% OUTPUTS:
%     imgout: adjusted image

% Modified Donald G. Dansereau 2013, minor fix: replace NaNs resulting from div-by-zero with zeros

% check input
if nargin<2 || isempty(win);
    win=round(min(size(img))/5);
end
if nargin<3 || isempty(th)
    th=1;
end


[mimg,stdv]=adaptstats(img,win);

imax=mimg+th*stdv;
imin=mimg-th*stdv;

% clip
imax(imax>1)=1;
imin(imin<0)=0;

imgout=(img-imin)./(imax-imin);

% adjust for clipping and saturation
imgout(imgout>1)=1;
imgout(imgout<0)=0;
imgout(isnan(imgout)) = 0; % replace nans, resulting from divide by zero above, with zeros

Contact us