⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ncg.m

📁 提出视频帧序列中最重要帧
💻 M
字号:
%ncg computes the Normed Centre of Gravity of an image.
%The NCG is a good statistic for block based watermarking which uses geometric warping.
%The NCG-strength (given by Lx and Ly) enables the estimation of the robustness of the NCG - x,y-cordinates to lossy compression.
%A higher strength yields a higher robustness.
%To embedd watermark bits the NCG - x,y-coordinate can be changed using
%geometric warping.
%
%You can find papers which base on this approach in:
%
%Pr鰂rock, D.; Schlauweg, M.; M黮ler, E.
%Video Watermarking by Using Geometric Warping Without Visible Artifacts
%Information Hiding (8th IH 2006), 10 -12 July 2006, Alexandria, USA
%
%Pr鰂rock, D.; Schlauweg, M.; M黮ler, E.:
%A New Uncompressed-domain Video Watermarking Approach robust to H.264/AVC
%Compression. Signal Processing, Pattern Recognition and Applications
%(SPPRA 2006), 15 - 17 February 2006, Innsbruck, Austria
%
%[Lx,Ly,x,y] = ncg(image) computes Lx,Ly,x,y
%		
%INPUT:
%	image --> nxm Matrix (only gray images)
%OUTPUT:
%   Lx   --> strength of the NCG - x-coordinate (probably if there are many vertical edges)
%   Ly   --> strength of the NCG - y-coordinate (probably if there are many horizontal edges)
%   x    --> NCG - x-coordinate
%   y    --> NCG - y-coordinate
%
%example: 
%image = zeros(16,40);
%image(4:7,15:20) = 255;
%[Lx,Ly,x,y] = ncg(image);
%
%Attention:
%This function computes the x,y-coordinates in range 0..imagesize.
%Matlab uses a range of 1..imagesize.
%To get the real Matlab NCG - x,y-coordinate you have to consider this (for example use an offset of 0.5 to get the real Matlab coordinates).

function [Lx Ly x y] = ncg(block)

blocksize = size(block); %get blocksize
vek = block_vek(block);  %computes Vx [vek(1,1),vek(1,2)] and Vy [vek(2,1),vek(2,2)])

%computes Lx and Ly
Lx = (vek(1,1)^2 + vek(1,2)^2)^0.5;
Ly = (vek(2,1)^2 + vek(2,2)^2)^0.5;

%computes x and y
x  = blocksize(2)*vek2wink(vek(1,1),vek(1,2))/(2*pi);
y  = blocksize(1)*vek2wink(vek(2,1),vek(2,2))/(2*pi);


%block_vek computes Vx and Vy
function [vek] = block_vek(block)

blocksize   = size(block);
%erstellen der Winkelvektoren
winkelvek_x = (pi/blocksize(2):2*pi/blocksize(2):(2*pi)-(pi/blocksize(2)));
winkelvek_y = (pi/blocksize(1):2*pi/blocksize(1):(2*pi)-(pi/blocksize(1)));
    
vert_m = mean(double(block)); 
vek(1,1) = sum(cos(winkelvek_x).*vert_m); 
vek(1,2) = sum(sin(winkelvek_x).*vert_m); 

hor_m = mean(double(block),2); 
vek(2,1) = sum(cos(winkelvek_y).*hor_m');
vek(2,2) = sum(sin(winkelvek_y).*hor_m');

%vek2wink computes the angel of one 2D-vector
function ergw = vek2wink(x,y)

if x ~= 0
    ergw = atan(abs(y/x));
else
    ergw = pi/2;
end

if x < 0 & y > 0
    ergw = pi - ergw;
elseif x < 0 & y < 0
    ergw = ergw + pi;
elseif x > 0 & y < 0
    ergw = 2*pi - ergw;
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -