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;
}
Aggregations