### start 2 colour flag

parent 7a5f82fd
 ... ... @@ -113,7 +113,7 @@ And the reconstructed black pixels will have RGB values (figure \ref{flagJAb}): \begin{equation} \col{\hat{R}}_b = 256\cdot \mathrm{e}^{-\begin{bmatrix} 0.5774 \\ 0.5774 \\ 0.5774 \end{bmatrix} \cdot 9.6045} - 1 = \begin{bmatrix} 0 \\ 0 \\ 0 \end{bmatrix} \label{flagJARb} \end{equation} If we wish to reconstruct the original flag with all three colours combined, we can \textsl{not} add the RGB images in figures \ref{flagJAy}--\ref{flagJAb}: that would be additive colour mixing for dyes that exhibit subtractive colour mixing. This is also obvious from adding e.g.\ the red values of the three dyes for the upper left (yellow) pixel: 252+255+255 (because that pixel in white in figures \ref{flagJAg}--\ref{flagJAb}) is not a proper' RGB value. If we wish to reconstruct the original flag with all three colours combined, we can \textsl{not} add the RGB images in figures \ref{flagJAy}--\ref{flagJAb}: that would be additive colour mixing for dyes that exhibit subtractive colour mixing. This is also obvious from adding e.g.\ the red values of the three dyes for the upper left (yellow) pixel: 252+255+255 (because that pixel is white in figures \ref{flagJAg}--\ref{flagJAb}) is not a proper' RGB value. Instead we have to combine the \textsl{absorption} contributions of the dyes and use: \begin{equation} ... ... @@ -121,17 +121,7 @@ Instead we have to combine the \textsl{absorption} contributions of the dyes an \end{equation} By multiplying the complete dye absorption matrix $\mat{K}$ with the complete column of (estimated) dye amounts $\col{\hat{a}}$ we ensure that all dye absorption effects are properly combined and accounted for (figure \ref{flagJAygb}). Note, by the way, that all RGB values in the fully reconstructed image (figure \ref{flagJAygb}) are a perfect match with the RGB values in the original flag (figure \ref{flagJA}). \begin{figure}[h!] \subfloat[RGB = 253, 244, 93\label{flagJAyn}]{% \includegraphics[width=0.47\linewidth]{pics/flagJAyn.png}}\hfill \subfloat[RGB = 96, 232, 196\label{flagJAgn}]{% \includegraphics[width=0.47\linewidth]{pics/flagJAgn.png}}\\ \subfloat[RGB = 142, 142, 142\label{flagJAbn}]{% \includegraphics[width=0.47\linewidth]{pics/flagJAbn.png}}\hfill \subfloat[\label{flagJAygbn}]{% \includegraphics[width=0.47\linewidth]{pics/flagJAygbn.png}}\\ \caption{Reconstructed RGB images with normalised dye absorption columns and $\hat{a} = 1$ for all dye amounts. With: \textbf{(a)} RGB image with contributions of only the normalised yellow dye; \textbf{(b)} RGB image with contributions of only the normalised green dye; \textbf{(c)} RGB image with contributions of only the normalised black dye; and \textbf{(d)} RGB image with contributions of all three normalised dyes together. \label{flagJAreconn}} \end{figure} \subsection{Normalisation} The dye absorption columns that were calculated from the dyes RGB values all had a certain length, a certain total absorption' over the three RGB channels. We normalised these absorption columns so that they all have a total absorption' over the three RGB channels of 1. \\ ... ... @@ -149,7 +139,17 @@ And that answer is, of course, $\abs{\col{A}_y}$.\\ \noindent So, this normalisation makes sure that the amount of dye that you used to obtain your reference dye colours' (RGB) or reference dye absorption columns, does not affect the outcome of the analysis (the estimated dye amounts). We therefore did not deconvolve with the actual colours (absorptions) in the flag, but with normalised colours' (absorptions) of the flag (figure \ref{flagJAreconn}). \begin{figure}[h!] \subfloat[RGB = 253, 244, 93\label{flagJAyn}]{% \includegraphics[width=0.47\linewidth]{pics/flagJAyn.png}}\hfill \subfloat[RGB = 96, 232, 196\label{flagJAgn}]{% \includegraphics[width=0.47\linewidth]{pics/flagJAgn.png}}\\ \subfloat[RGB = 142, 142, 142\label{flagJAbn}]{% \includegraphics[width=0.47\linewidth]{pics/flagJAbn.png}}\hfill \subfloat[\label{flagJAygbn}]{% \includegraphics[width=0.47\linewidth]{pics/flagJAygbn.png}}\\ \caption{Reconstructed RGB images with normalised dye absorption columns and $\hat{a} = 1$ for all dye amounts. With: \textbf{(a)} RGB image with contributions of only the normalised yellow dye; \textbf{(b)} RGB image with contributions of only the normalised green dye; \textbf{(c)} RGB image with contributions of only the normalised black dye; and \textbf{(d)} RGB image with contributions of all three normalised dyes together. \label{flagJAreconn}} \end{figure} ... ...
 clear all; close all; % read image im = imread('pics/Flag_of_Jamaica.png'); % image colours dyes = [254 209 0; % yellow 0 155 58 % green 0 0 0]'; % black % do the deconvolve [amounts, P, Q, R, RGB, A, K, iOD] = cld_decon(dyes, im, 'rgb'); % show image figure imshow(im) for d = 1:3 figure imshow(amounts(:, :, d)/norm(A(:, d))) colormap(gray) colorbar end figure imshow(sum(amounts, 3)/10) colormap(gray) colorbar figure imshow(uint8(round(P))) % imwrite(uint8(P), 'pics/flagJAy.png', 'PNG') figure imshow(uint8(round(Q))) % imwrite(uint8(Q), 'pics/flagJAg.png', 'PNG') figure imshow(uint8(round(R))) % imwrite(uint8(R), 'pics/flagJAb.png', 'PNG') figure imshow(uint8(round(RGB))) % imwrite(uint8(RGB), 'pics/flagJAygb.png', 'PNG') % normalised deconvolution colours p = 0; done = -1; Imax = 255; for r = 1:size(im, 1) for c = 1:size(im, 2) p = p + 1; % update pixel count if round(100*p/(numel(im)/3)) > done % update feedback done = round(100*p/(numel(im)/3)); fprintf('\b\b\b\b\b\b\b\b\b%3i%% done', done) end pam = squeeze(amounts(r, c, :)); pam = pam/max(pam); % reconstruct pixels RGB contributions [RGB(r, c, :), PQR] = cld_od2rgb(K, pam, Imax); P(r, c, :) = PQR(:, 1); Q(r, c, :) = PQR(:, 2); R(r, c, :) = PQR(:, 3); end end figure imshow(uint8(round(P))) % imwrite(uint8(P), 'pics/flagJAyn.png', 'PNG') figure imshow(uint8(round(Q))) % imwrite(uint8(Q), 'pics/flagJAgn.png', 'PNG') figure imshow(uint8(round(R))) % imwrite(uint8(R), 'pics/flagJAbn.png', 'PNG') figure imshow(uint8(round(RGB))) % imwrite(uint8(RGB), 'pics/flagJAygbn.png', 'PNG')
 ... ... @@ -26,7 +26,7 @@ for d = 1:3 end figure imshow(sum(amounts, 3)/norm(A(:, 3))) imshow(sum(amounts, 3)/10) colormap(gray) colorbar ... ...
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!