Image copy detection
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 169 Accepted Submission(s): 114
For those above purposes, the image copy detection system came out.It aggregated all the images which were viewed as a copy of original image.In this system,an image is partitioned into m×n equalsized blocks,which makes the system independent of input image sizes,and an m×n sub-image is calculated by taking the average value of each block(see Figure.1(b)), This array is converted to a rank matrix as shown in Fig.1(c).Suppose that the intensity values in Fig.1(b) are changed in the copied image so that its sub-image has values:{{30, 60, 40}, {70, 90, 110}, {50, 100, 80}}. Nevertheless,its rank matrix is identical to that shown in Fig. 1(c) and thus perfect matching with original image can be achieved.
Fig.1 (a)An image is divided into m×n blocks (3×3 in this example),(b)average values of blocks, and(c)rank matrix of (b). Let T and Q represent test image and original image,N represent the matrix size;there exists N tuples (t1,q1),…,( tn,qn),…,( tN,qN)(the order of the rank matrix:from left to right and from top to bottom).Now we define D(T,Q) =
measures the distance between the two images(it’s obvious that if D(T,Q) gets smaller while the probability of the test image is considered as a copy of original image by the system becomes larger). Since there are M original images in the image copy detection system(Q1…QM). And the distance between T and some original images is given by D(T,Q1…QM)=
To make it simple,we want to find an image which owns least D(T,Q1…QM).
3 2
1 2 3
1 3 2
9 3
1 4 2 5 7 9 3 8 6
2 1 4 5 9 3 7 6 8
9 8 7 6 5 4 3 2 1
Case #2: 58
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#include<cstdio>
#define N 105
#define inf 999999999
int t,tt,n,m,d,a[N][N],lx[N],ly[N],w[N][N],pre[N];
bool bx[N],by[N];
int dfs(int u)
{
int v,t;
bx[u]=1;
for(v=1;v<=n;v++)
if(!by[v])
{
t=lx[u]+ly[v]-w[u][v];
if(t)
d=min(d,t);
else
{
by[v]=1;
if(pre[v]==-1||dfs(pre[v]))
{
pre[v]=u;
return 1;
}
}
}
return 0;
}
int KM()
{
int i,j,ans=0;
for(i=1;i<=n;i++)
{
pre[i]=-1;
lx[i]=-inf;
ly[i]=0;
for(j=1;j<=n;j++)
lx[i]=max(lx[i],w[i][j]);
}
for(i=1;i<=n;i++)
while(1)
{
d=inf;
for(j=1;j<=n;j++)
bx[j]=by[j]=0;
if(dfs(i))
break;
for(j=1;j<=n;j++)
{
if(bx[j])
lx[j]-=d;
if(by[j])
ly[j]+=d;
}
}
for(i=1;i<=n;i++)
ans+=w[pre[i]][i];
return ans;
}
int main()
{
scanf("%d",&t);
while(t--)
{
scanf("%d%d",&n,&m);
int i,j,k;
for(i=1;i<=m;i++)
for(j=1;j<=n;j++)
scanf("%d",&a[i][j]);
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
{
w[i][j]=0;
for(k=1;k<=m;k++)
w[i][j]-=abs(a[k][i]-j);
}
printf("Case #%d: %d\n",++tt,-KM());
}
}
286



被折叠的 条评论
为什么被折叠?



