Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Java SE 综合讨论区 » 编程/算法/API  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 哪位能够给个AAN 的dct 和idct 算法? 或者能解释下下面的算法吗
zhulei420





发贴: 1
积分: 0
于 2009-04-26 20:10 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
private void initMatrix(int quality) {
int i;
int j;

for (i = 0; i < N; i++) {
for (j = 0; j < N; j++) {
quantum[i][j] = (1 + ((1 + i + j) * quality));
}
}

for (j = 0; j < N; j++) {
double nn = (double) (N);
c[0][j] = 1.0 / Math.sqrt(nn);
cT[j][0] = c[0][j];
}

for (i = 1; i < 8; i++) {
for (j = 0; j < 8; j++) {
double jj = (double) j;
double ii = (double) i;
c[i][j] = Math.sqrt(2.0 / 8.0)
* Math.cos(((2.0 * jj + 1.0) * ii * Math.PI)
/ (2.0 * 8.0));
cT[j][i] = c[i][j];
}
}
}
public int[][] forwardDCT(int input[][]) {
int output[][] = new int[N][N];
double temp[][] = new double[N][N];
double temp1;
int i;
int j;
int k;
for (i = 0; i < N; i++) {
for (j = 0; j < N; j++) {
temp[i][j] = 0.0;
for (k = 0; k < N; k++) {
temp[i][j] += (((int) (input[i][k]) - 128) * cT[k][j]);
}
}
}

for (i = 0; i < N; i++) {
for (j = 0; j < N; j++) {
temp1 = 0.0;

for (k = 0; k < N; k++) {
temp1 += (c[i][k] * temp[k][j]);
}
output[i][j] = (int) Math.round(temp1);
}
}
return output;
}

public int[][] inverseDCT(int input[][]) {
int output[][] = new int[N][N];
double temp[][] = new double[N][N];
double temp1;
int i;
int j;
int k;
for (i = 0; i < N; i++) {
for (j = 0; j < N; j++) {
temp[i][j] = 0.0;
for (k = 0; k < N; k++) {
temp[i][j] += input[i][k] * c[k][j];
}
}
}

for (i = 0; i < N; i++) {
for (j = 0; j < N; j++) {
temp1 = 0.0;

for (k = 0; k < N; k++) {
temp1 += cT[i][k] * temp[k][j];
}
temp1 += 128.0;

if (temp1 < 0) {
output[i][j] = 0;
} else if (temp1 > 255) {
output[i][j] = 255;
} else {
output[i][j] = (int) Math.round(temp1);
}
}
}

return output;
}




话题树型展开
人气 标题 作者 字数 发贴时间
12328 哪位能够给个AAN 的dct 和idct 算法? 或者能解释下下面的算法吗 zhulei420 1734 2009-04-26 20:10

flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923