function  [R, Rv]  =  TVpreprocess( TTalpha, PTP, Par, ImageH, ImageW )
   PatSize=Par.patsize;
    TempR        =   ImageH-PatSize+1;
    TempC        =   ImageW-PatSize+1;
    TempOffsetR  =   [1:TempR];
    TempOffsetC  =   [1:TempC];    

    Rv  	=  zeros(ImageH,ImageW);
    R 	=  zeros(ImageH,ImageW);
    k        =   0;
    for j  = 1:PatSize
     for i  = 1:PatSize
            k    =  k+1;
            Rv(TempOffsetR-1+i,TempOffsetC-1+j)  =  Rv(TempOffsetR-1+i,TempOffsetC-1+j) + reshape( TTalpha(k,:)', [TempR TempC]);
            R(TempOffsetR-1+i,TempOffsetC-1+j)  =  R(TempOffsetR-1+i,TempOffsetC-1+j) + reshape( PTP(k,:)',  [TempR TempC]);
        end
    end