Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
collinswakholi committed Jul 7, 2021
1 parent 264ab92 commit adb4e53
Show file tree
Hide file tree
Showing 24 changed files with 2,876 additions and 0 deletions.
Binary file added G1_1_9.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2018-present Fabio Spampinato

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
69 changes: 69 additions & 0 deletions ccmapply.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
function predicted_responses = ccmapply(camera_responses,...
model,...
matrix,...
scale)
% CCMAPPLY converts the camera responses into the corrected color responses,
% via a scaling factor and a color correction matrix.
%
% INPUTS:
% camera_responses: Nx3 camera linear RGB responses to be validated, in
% the range 0-1, with darkness level subtracted. (can
% also be XYZ responses in some particular cases)
% model: color correction model, based on which the camera
% responses will be expanded.
% 'linear3x3' (default) | 'root6x3' | 'root13x3' |
% 'poly4x3' | 'poly6x3' | 'poly7x3' | 'poly9x3'
% matrix: color correction matrix, the size of which must match
% 'model'.
% scale: the scaling factor. Camera responses will be first
% scaled by this factor and then be expanded and
% multiplied. (default = 1)
%
% OUTPUTS:
% predicted_responses: the color corrected responses predicted by 'scale'
% and 'matrix', i.e., predicted_responses =
% (scale * expanded_camera_responses) * matrix
%
% Copyright
% Qiu Jueqin - Feb, 2019

% check the inputs
assert(size(camera_responses, 2) == 3,...
'Test responses must be a Nx3 matrix.');
assert(max(camera_responses(:)) <= 1 && min(camera_responses(:)) >= 0,...
'Test responses must be in the range of [0, 1]. Normalize them before color correction.');

% check the color correction model
models_list = {'linear3x3',...
'root6x3', 'root13x3',...
'poly4x3', 'poly6x3', 'poly7x3', 'poly9x3'};
if ~ismember(lower(model), models_list)
error('%s is not a valid color correction model. Only following models are supported:\n%s',...
param.model, strjoin(models_list, ' | '));
end

% determine the number of terms
term_num = regexp(model, '(\d{1,2})x', 'tokens');
term_num = str2double(term_num{1}{1});

% check the matrix
if size(matrix, 1) == term_num + 1
add_bias = true;
elseif size(matrix, 1) == term_num
add_bias = false;
else
error('The model ''%s'' and the matrix do not match.', model);
end

% scaling
if nargin < 4 || isempty(scale) || scale <= 0
scale = 1;
end
camera_responses = scale * camera_responses;
camera_responses = max(min(camera_responses, 1), 0);

% expand the camera responses
expanded_camera_responses = response_expand(camera_responses, model, add_bias);

% color correction
predicted_responses = expanded_camera_responses * matrix;
Loading

0 comments on commit adb4e53

Please sign in to comment.