Search in sources :

Example 1 with ImageFeature

use of de.neotos.imageanalyzer.ImageFeature in project mlib by myshzzx.

the class GrayScaleFeaturesLimit method process.

public List<ImageFeature> process(BufferedImage img) {
    ColorConvertOp colorFilter = new ColorConvertOp(ColorSpace.getInstance(ColorSpace.CS_GRAY), null);
    BufferedImage grayImg = colorFilter.filter(img, null);
    int w = img.getWidth(null);
    int h = img.getHeight(null);
    double ratio;
    if (initPx > w && initPx > h)
        ratio = 1;
    else
        ratio = w > h ? initPx * 1.0 / w : initPx * 1.0 / h;
    List<ImageFeature> features;
    int fSize;
    while (true) {
        features = fe.getFeatures(grayImg.getScaledInstance((int) (w * ratio), (int) (h * ratio), Image.SCALE_AREA_AVERAGING));
        fSize = features.size();
        if (fSize < fLimit)
            break;
        ratio /= 1.2;
    }
    log.debug((int) (w * ratio) + "*" + (int) (h * ratio) + ", features: " + features.size());
    return features;
}
Also used : ColorConvertOp(java.awt.image.ColorConvertOp) ImageFeature(de.neotos.imageanalyzer.ImageFeature) BufferedImage(java.awt.image.BufferedImage)

Aggregations

ImageFeature (de.neotos.imageanalyzer.ImageFeature)1 BufferedImage (java.awt.image.BufferedImage)1 ColorConvertOp (java.awt.image.ColorConvertOp)1