| OLD | NEW |
| 1 % Create the color enhancement look-up table and write it to | 1 % Create the color enhancement look-up table and write it to |
| 2 % file colorEnhancementTable.cpp. Copy contents of that file into | 2 % file colorEnhancementTable.cpp. Copy contents of that file into |
| 3 % the source file for the color enhancement function. | 3 % the source file for the color enhancement function. |
| 4 | 4 |
| 5 clear | 5 clear |
| 6 close all | 6 close all |
| 7 | 7 |
| 8 | 8 |
| 9 % First, define the color enhancement in a normalized domain | 9 % First, define the color enhancement in a normalized domain |
| 10 | 10 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 B=0.2; % initial slope of compander function (between 0 and 1) | 24 B=0.2; % initial slope of compander function (between 0 and 1) |
| 25 | 25 |
| 26 x0=linspace(0,r0).'; % zone 1 | 26 x0=linspace(0,r0).'; % zone 1 |
| 27 x1=linspace(r0,r1).'; % zone 2 | 27 x1=linspace(r0,r1).'; % zone 2 |
| 28 x2=linspace(r1,1).'; % zone 3 | 28 x2=linspace(r1,1).'; % zone 3 |
| 29 | 29 |
| 30 A=(1-B)/r0; | 30 A=(1-B)/r0; |
| 31 f0=A*x0.^2+B*x0; % compander function in zone 1 | 31 f0=A*x0.^2+B*x0; % compander function in zone 1 |
| 32 | 32 |
| 33 % equation system for finding second zone parameters | 33 % equation system for finding second zone parameters |
| 34 M=[r0^3 r0^2 r0 1; | 34 M=[r0^3 r0^2 r0 1; |
| 35 3*r0^2 2*r0 1 0; | 35 3*r0^2 2*r0 1 0; |
| 36 3*r1^2 2*r1 1 0; | 36 3*r1^2 2*r1 1 0; |
| 37 r1^3 r1^2 r1 1]; | 37 r1^3 r1^2 r1 1]; |
| 38 m=[A*r0^2+B*r0; 2*A*r0+B; 1; r1]; | 38 m=[A*r0^2+B*r0; 2*A*r0+B; 1; r1]; |
| 39 % solve equations | 39 % solve equations |
| 40 theta=M\m; | 40 theta=M\m; |
| 41 | 41 |
| 42 % compander function in zone 1 | 42 % compander function in zone 1 |
| 43 f1=[x1.^3 x1.^2 x1 ones(size(x1))]*theta; | 43 f1=[x1.^3 x1.^2 x1 ones(size(x1))]*theta; |
| 44 | 44 |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 % traverse all frames | 166 % traverse all frames |
| 167 for k=1:size(y,3) | 167 for k=1:size(y,3) |
| 168 fprintf('Frame %i\n', k); | 168 fprintf('Frame %i\n', k); |
| 169 for r=1:size(u,1) | 169 for r=1:size(u,1) |
| 170 for c=1:size(u,2) | 170 for c=1:size(u,2) |
| 171 unew(r,c,k) = uint8(U(double(v(r,c,k))+1, double(u(r,c,k))+1)); | 171 unew(r,c,k) = uint8(U(double(v(r,c,k))+1, double(u(r,c,k))+1)); |
| 172 vnew(r,c,k) = uint8(V(double(v(r,c,k))+1, double(u(r,c,k))+1)); | 172 vnew(r,c,k) = uint8(V(double(v(r,c,k))+1, double(u(r,c,k))+1)); |
| 173 end | 173 end |
| 174 end | 174 end |
| 175 end | 175 end |
| 176 | 176 |
| 177 fprintf('\nWriting modified test file...') | 177 fprintf('\nWriting modified test file...') |
| 178 writeYUV420file('../out/Debug/foremanColorEnhanced.yuv',y,unew,vnew); | 178 writeYUV420file('../out/Debug/foremanColorEnhanced.yuv',y,unew,vnew); |
| 179 fprintf(' done\n'); | 179 fprintf(' done\n'); |
| OLD | NEW |