classdef SSIMVideoMetricItem < FFMPEGVideoDecoderMetricItem
    
    
    
    methods
        function obj=SSIMVideoMetricItem
            obj=obj@FFMPEGVideoDecoderMetricItem('AVG-SSIM');
        end
        
        function m=calc_color_imagemetric(obj,fname1,fname2)
            
            image1=(imread(fname1));
            image2=(imread(fname2));
            
            %image1=imresize(image1,0.25);
            %image2=imresize(image2,0.25);
            
            image1=rgb2ycbcr(image1);
            image2=rgb2ycbcr(image2);
            
                [mssimy, ssim_mapy] = ssim(image1(:,:,1),image2(:,:,1));
                [mssimcb, ssim_mapcb] = ssim(image1(:,:,2),image2(:,:,2));
                [mssimcr, ssim_mapcr] = ssim(image1(:,:,3),image2(:,:,3));
            
                m=0.8*mssimy+0.1*mssimcb+0.1*mssimcr;
        end
        
        
        
    end
    
end