在java中找到LBP代码

时间:2015-09-21 07:28:36

标签: java image-processing

您好我是Java新手,并尝试使用线性二进制模式开发人脸识别系统。我正在尝试计算图像的LBP代码以识别面部。但无法弄清楚如何做到这一点。我使用下面的代码分割图像。但是当时找不到LBP代码。

package project;

import javax.imageio.ImageIO;  
import java.awt.image.BufferedImage;  
import java.io.*;  
import java.awt.*;  

public class ImageSplitTest 
{  
public void split(String s) throws IOException
{
    File file = new File(s);
    BufferedImage image = ImageIO.read(file);

    int rows = 3;
    int cols = 3;  
    int chunks = rows * cols;  

    int chunkWidth = image.getWidth() / cols;   
    int chunkHeight = image.getHeight() / rows;  
    int count = 0;  
    BufferedImage imgs[] = new BufferedImage[chunks]; 

    for (int x = 0; x < rows; x++) 
    {  
        for (int y = 0; y < cols; y++) 
        {  
            imgs[count] = new BufferedImage(chunkWidth, chunkHeight, image.getType());  
            Graphics2D gr = imgs[count++].createGraphics();  
            gr.drawImage(image, 0, 0, chunkWidth, chunkHeight, chunkWidth * y, chunkHeight * x, chunkWidth * y + chunkWidth, chunkHeight * x + chunkHeight, null);  
            gr.dispose();  
        }  
    }  
    System.out.println("Splitting done");  


    for (int i = 0; i < imgs.length; i++) {  
        ImageIO.write(imgs[i], "jpg", new File("img" + i + ".jpg"));  
    }  
    System.out.println("Mini images created");  
}  
}  

这是按照LBP算法划分图像的正确方法

0 个答案:

没有答案