| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 770 人关注过本帖
标题:希望各位大神看看,代码有点长,新手希望大家多多赐教
取消只看楼主 加入收藏
王新勃
Rank: 1
来 自:陕西西安
等 级:新手上路
帖 子:5
专家分:0
注 册:2013-9-15
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:1 
希望各位大神看看,代码有点长,新手希望大家多多赐教
package jianmo;

import java.awt.image.BufferedImage;
import
import java.util.TreeMap;

import javax.imageio.ImageIO;

public class T01 {
        
    public static void main(String[] args) {
        TreeMap<String,String> fileList = FileName.getFile("C:\\Users\\王春晓\\Desktop\\cumcm2013problems\\B\\附件1\\");
        for(String s : fileList.keySet()){
            //System.out.println(s+"\t"+fileList.get(s));
    FileList fileList = getFileList("C:\\Users\\王春晓\\Desktop\\cumcm2013problems\\B\\附件\\"); // get file name list from a folder
            int fileNum = fileList.size();   //get the number of file names
        
            BufferedImage bImg = new BufferedImage(fileList[0].getFileName());
            int iHeight = bImg.getHeight();  // Image Height
            int iWidth = bImg.getWidth();     // Image Width
            bImg.close();
            int[][] leftArr = new int[fileNum][iHeight];        //left edge array
            int[][] rightArr = new int[fileNum][iHeight];        //right edge array

            // get the leftArr and rightArr
            int i;int j;
            for(i = 0; i < fileNum; ++i)
            {3
                BufferedImage tImg = new BufferedImage(fileList[i].getFileName());
                for(j = 0; j < iHeight; ++j)
                {
                    leftArr[i][j] = tImg.getRGB(0, j);
                    rightArr[i][j] = tImg.getRGB(iWidth - 1, j);
                }
            }

            // calculate the distance between each image
            double[][] distMat = new double[fileNum][fileNum];
            for(i = 0; i < fileNum; ++i)
            {
                // use a image's left edge compare with other images' right edge
                for(j = 0; j < fileNum; ++j)
                {
                    double tDist = 0; int k; // distance between image[i]' left edge and image[j]' right edge
                    for(k = 0; k < iHeight; ++k)
                        
                    {
                        tDist += getDistance(left[i][k], right[j][k];
                    }
                    distMat[i][j] = tDist;
                }
            }

            // TODO: we have the distance matrix between each images, so we should
            //       have an algorithm to match the images.
            // ...
        }

        // get the distance of two RGB point, using Euclidean distance
        // distance lower is better
        double getDistance(int aRGB; int bRGB);
        {
            double dist = 0.0;
            int aR = (aRGB & 0x00ff0000) >> 16;
            int bR = (bRGB & 0x00ff0000) >> 16;
            int aG = (aRGB & 0x0000ff00) >> 8;
            int bG = (bRGB & 0x0000ff00) >> 8;
            int aB = aRGB & 0x000000ff;
            int bB = bRGB & 0x000000ff;
            double sqrt;
            dist = sqr(((aR - bR) * (aR - bR) +
                         (aG - bG) * (aG - bG) +
                         (aB - bB) * (aB - bB))
                        * 1.0);
        
        }
// TODO Auto-generated method stub

    }

    private static double sqr(double d) {
        // TODO Auto-generated method stub
        return 0;
    }

}
这个程序在eclipse上运行有错误,希望大神讲详细点,谢谢。。。
搜索更多相关主题的帖子: import public package Desktop Users 
2013-09-15 17:12
王新勃
Rank: 1
来 自:陕西西安
等 级:新手上路
帖 子:5
专家分:0
注 册:2013-9-15
收藏
得分:0 
好的
2013-09-16 15:48
快速回复:希望各位大神看看,代码有点长,新手希望大家多多赐教
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.031421 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved