function imgRec = PNGHDRDec(name) % % % imgRec = PNGHDRDec(img) % % Author: Francesco Banterle % Copyright July 2010 (c) % % Input: % % -name: is the name of an PNGHDR image. % %Reading PNGHDR file [img, map, alpha] = imread(name); imshow(alpha); %Removing gamma img = (double(img)/255).^2; alpha = (double(alpha)/255).^2; %Ratio decoding RI = 2.^(alpha*32-16)-2^-16; RI(find(RI<0))=0; imgRec = zeros(size(img)); for i=1:3 imgRec(:,:,i) = img(:,:,i).*RI; end end