function [QS1, QS2]=LQMScore( colorimage, dataimage, depthimage )

%%
% colorimage = imread('lovebird1_c_8(112)_1024x768.bmp');
% dataimage= imread('Fehn_interpolated_Lovebird1_bh_8_to_6_IV_112.bmp');
% 
% depthimage = yuv_import('lovebird1_d_8(112)_1024x768.yuv', [1024 768],0 ,'YUV420_8');
% [Dly,Dlv,Dlu]=yuv_import('lovebird1_d_8(112)_1024x768.yuv', [1024 768],0 ,'YUV420_8');
% 
% depthValue_left = Dly/255*(1/zNearLeft - 1/zFarLeft) + 1/zFarLeft;
%% 

[rows, cols, colors] = size(depthimage);
if colors == 3
    depthimage = depthimage(:,:,1);
end
Histo = uint8(depthimage);
I = imhist(Histo,32);
TF = islocalmin(I,'MaxNumExtrema',1);
%x = 1:32;
%TF = islocalmin(I);
% plot(x,I,x(TF),I(TF),'r*')
% axis tight


j=1;
obj = struct('s', {},'e',{});
A = zeros(32,1);
for i=1:32
   
    if( TF(i) == 1)
         A(j)= i;
         j=j+1;
        
     end
   
end
[r, c]=size(A);

obj(1).s= 1;
obj(1).e =A(1)*8;
j=2;
for i=1:c
    if ( i==1 )
        obj(i).s=1;
        obj(i).e=A(i)*8;
   end
end
 i=i+1;
 obj(i).s = obj(i-1).e+1;
 obj(i).e= 32*8;

pic1=colorimage ;
% [r, c, pd]=size(pic1);
pic2=colorimage ;
% [r, c, pd]=size(pic2);
image3 = dataimage ;
% [r, c pd]=size(image3);
image4 =dataimage ;
% [r, c pd]=size(image4);


[r1 c1]=size(obj);
[ro, co]=size(depthimage);
for i=1:c1
    l=obj(i).s;
    u=obj(i).e;
    index=find(depthimage >=l & depthimage <=u);
    layer(index)=i;
end

layer=reshape(layer,rows,[]);
% vLayer = layer;
%Warping
% [ vRY, vRU, vRV, RightShift, holes,vLayer] = RVV(Dly,Dlv,Dlu, depthValue_left, height, width, f, b,layer);
index=find(layer==0);
layer(index)=0;


case1 = (~(layer==1));
idx= find(case1);
pic1(idx)=0;
pic1(idx+r*c)=0;
pic1(idx+2*r*c)=0;

% case3 = (~(layer==1));
% idx= find(case3);
image3(idx)=0;
image3(idx+r*c)=0;
image3(idx+2*r*c)=0;


case2 = (~(layer==2));
idx= find(case2);
pic2(idx)=0;
pic2(idx+r*c)=0;
pic2(idx+2*r*c)=0;

% case4 = (~(layer==2));
% idx= find(case4);
image4(idx)=0;
image4(idx+r*c)=0;
image4(idx+2*r*c)=0;

% figure, imshow([pic1 pic2; image3 image4]);

QS1 = metrix_mux(pic1,image3,'WSNR'); 
QS2 = metrix_mux(pic2,image4,'WNSR'); 
 
end


