frcs-colour-transfer

Форк
0
/
colour_transfer_IDT.m 
47 строк · 1.3 Кб
1
%
2
%   colour transfer algorithm based on N-Dimensional PDF Transfer 
3
%
4
%   IR = colour_transfer_IDT(I_original, I_target, nb_iterations);
5
%
6
%  (c) F. Pitie 2007
7
%
8
%  see reference:
9
%     Automated colour grading using colour distribution transfer. (2007) 
10
%     Computer Vision and Image Understanding.
11
%
12
%  To remove the "grainyness" on the results, you should apply the grain 
13
%  reducer proposed in the paper and implemented in regrain.m:
14
%
15
%  IRR = regrain(I_original, IR);
16
%
17
function IR = colour_transfer_IDT(I0, I1, nb_iterations)
18

19
if (ndims(I0)~=3)
20
    error('pictures must have 3 dimensions');
21
end
22

23
nb_channels = size(I0,3);
24

25
%% reshape images as 3xN matrices
26
for i=1:nb_channels
27
    D0(i,:) = reshape(I0(:,:,i), 1, size(I0,1)*size(I0,2));
28
    D1(i,:) = reshape(I1(:,:,i), 1, size(I1,1)*size(I1,2));
29
end
30

31
%% building a sequence of (almost) random projections
32
% 
33

34
R{1} = [1 0 0; 0 1 0; 0 0 1; 2/3 2/3 -1/3; 2/3 -1/3 2/3; -1/3 2/3 2/3];
35
for i=2:nb_iterations
36
      R{i} = R{1} * orth(randn(3,3));
37
end
38

39
%for i=2:nb_iterations, R{i} = R{1}; end
40
%% pdf transfer
41
DR = pdf_transfer(D0, D1, R, 1);
42

43
%% reshape the resulting 3xN matrix as an image
44
IR = I0;
45
for i=1:nb_channels
46
    IR(:,:,i) = reshape(DR(i,:), size(IR, 1), size(IR, 2));
47
end
48

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.