
com.github.axet.lookup.common.ImageBinaryGreyFeature Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lookup Show documentation
Show all versions of lookup Show documentation
lookup java OCR / sub image find library
package com.github.axet.lookup.common;
import java.awt.image.BufferedImage;
import java.util.Arrays;
import java.util.List;
import com.github.axet.lookup.common.ImageBinaryChannel.ChannelType;
/**
* Container for ImageBinary and Feature class for each channel (one gray channel here)
*
* @author axet
*
*/
public class ImageBinaryGreyFeature implements ImageBinaryFeature {
public RGBImage image;
public ImageBinaryChannelFeature grey;
public List list;
public ImageBinaryGreyFeature(BufferedImage img, double threshold) {
init(img);
FeatureSet lr = new FeatureSetAuto(grey, threshold);
grey.init(lr);
}
public void init(BufferedImage img) {
image = new RGBImage();
grey = new ImageBinaryChannelFeature(ChannelType.GREY);
list = Arrays.asList(new ImageBinaryChannelFeature[] { grey });
this.image.init(img);
this.grey.initBase(this.image.r);
for (int x = 0; x < this.image.cx; x++) {
for (int y = 0; y < this.image.cy; y++) {
this.image.step(x, y);
this.grey.step(x, y);
}
}
grey.zeroMean = new ImageZeroMean();
grey.zeroMean.init(grey.integral);
for (int x = 0; x < this.image.cx; x++) {
for (int y = 0; y < this.image.cy; y++) {
grey.zeroMean.step(x, y);
}
}
grey.zeroMeanIntegral = new IntegralImage();
grey.zeroMeanIntegral.initBase(grey.zeroMean);
for (int x = 0; x < this.image.cx; x++) {
for (int y = 0; y < this.image.cy; y++) {
grey.zeroMeanIntegral.step(x, y);
}
}
}
public int getWidth() {
return image.cx;
}
public int getHeight() {
return image.cy;
}
public int size() {
return image.cx * image.cy;
}
public BufferedImage getImage() {
return image.buf;
}
@Override
public List getFeatureChannels() {
return list;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy