本文整理汇总了Java中boofcv.alg.descriptor.UtilFeature类的典型用法代码示例。如果您正苦于以下问题:Java UtilFeature类的具体用法?Java UtilFeature怎么用?Java UtilFeature使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
UtilFeature类属于boofcv.alg.descriptor包,在下文中一共展示了UtilFeature类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readIn
import boofcv.alg.descriptor.UtilFeature; //导入依赖的package包/类
public static ImageDesc readIn(ByteBuffer buf)
{
FastQueue<BrightFeature> des = UtilFeature.createQueue(detDesc,0);
int dts = buf.getInt();
for(int i=0;i<dts;i++)
{
int vs = buf.getInt();
BrightFeature f = new BrightFeature(vs);
double[] vls = new double[vs];
for(int j=0;j<vs;j++)
{
vls[j]=buf.getDouble();
}
f.set(vls);
des.add(f);
}
AverageHash h = AverageHash.readIn(buf);
return new ImageDesc(des,h);
}
示例2: coupledHueSat
import boofcv.alg.descriptor.UtilFeature; //导入依赖的package包/类
/**
* HSV stores color information in Hue and Saturation while intensity is in Value. This computes a 2D histogram
* from hue and saturation only, which makes it lighting independent.
*/
public static double[] coupledHueSat(BufferedImage image) {
Planar<GrayF32> rgb = new Planar<>(GrayF32.class, image.getWidth(), image.getHeight(), 3);
Planar<GrayF32> hsv = new Planar<>(GrayF32.class, image.getWidth(), image.getHeight(), 3);
ConvertBufferedImage.convertFrom(image, rgb, true);
ColorHsv.rgbToHsv_F32(rgb, hsv);
Planar<GrayF32> hs = hsv.partialSpectrum(0, 1);
// The number of bins is an important parameter. Try adjusting it
Histogram_F64 histogram = new Histogram_F64(10, 10);
histogram.setRange(0, 0, 2.0 * Math.PI); // range of hue is from 0 to 2PI
histogram.setRange(1, 0, 1.0); // range of saturation is from 0 to 1
// Compute the histogram
GHistogramFeatureOps.histogram(hs, histogram);
histogram.value[0] = 0.0; // remove black
UtilFeature.normalizeL2(histogram); // normalize so that image size doesn't matter
return histogram.value;
}
示例3: coupledRGB
import boofcv.alg.descriptor.UtilFeature; //导入依赖的package包/类
/**
* Constructs a 3D histogram using RGB. RGB is a popular color space, but the resulting histogram will
* depend on lighting conditions and might not produce the accurate results.
*/
public static double[] coupledRGB(BufferedImage image) {
Planar<GrayF32> rgb = new Planar<>(GrayF32.class,1,1,3);
rgb.reshape(image.getWidth(), image.getHeight());
ConvertBufferedImage.convertFrom(image, rgb, true);
// The number of bins is an important parameter. Try adjusting it
Histogram_F64 histogram = new Histogram_F64(5,5,5);
histogram.setRange(0, 0, 255);
histogram.setRange(1, 0, 255);
histogram.setRange(2, 0, 255);
GHistogramFeatureOps.histogram(rgb,histogram);
histogram.value[0] = 0.0; // remove black
UtilFeature.normalizeL2(histogram); // normalize so that image size doesn't matter
return histogram.value;
}
示例4: independentHueSat
import boofcv.alg.descriptor.UtilFeature; //导入依赖的package包/类
/**
* Computes two independent 1D histograms from hue and saturation. Less affects by sparsity, but can produce
* worse results since the basic assumption that hue and saturation are decoupled is most of the time false.
*/
public static double[] independentHueSat(BufferedImage image) {
// The number of bins is an important parameter. Try adjusting it
TupleDesc_F64 histogramHue = new TupleDesc_F64(5);
TupleDesc_F64 histogramValue = new TupleDesc_F64(5);
List<TupleDesc_F64> histogramList = new ArrayList<>();
histogramList.add(histogramHue); histogramList.add(histogramValue);
Planar<GrayF32> rgb = new Planar<>(GrayF32.class,1,1,3);
Planar<GrayF32> hsv = new Planar<>(GrayF32.class,1,1,3);
rgb.reshape(image.getWidth(), image.getHeight());
hsv.reshape(image.getWidth(), image.getHeight());
ConvertBufferedImage.convertFrom(image, rgb, true);
ColorHsv.rgbToHsv_F32(rgb, hsv);
GHistogramFeatureOps.histogram(hsv.getBand(0), 0, 2*Math.PI,histogramHue);
GHistogramFeatureOps.histogram(hsv.getBand(1), 0, 1, histogramValue);
// need to combine them into a single descriptor for processing later on
TupleDesc_F64 imageHist = UtilFeature.combine(histogramList,null);
UtilFeature.normalizeL2(imageHist); // normalize so that image size doesn't matter
return imageHist.value;
}
示例5: coupledHueSat
import boofcv.alg.descriptor.UtilFeature; //导入依赖的package包/类
/**
* HSV stores color information in Hue and Saturation while intensity is in Value. This computes a 2D histogram
* from hue and saturation only, which makes it lighting independent.
*/
public double[] coupledHueSat(byte[] image) throws IOException {
Planar<GrayF32> rgb = new Planar<GrayF32>(GrayF32.class,1,1,3);
Planar<GrayF32> hsv = new Planar<GrayF32>(GrayF32.class,1,1,3);
BufferedImage buffered = ImageIO.read(new ByteArrayInputStream(image));
if (buffered == null) {
throw new RuntimeException("Can't load image!");
}
rgb.reshape(buffered.getWidth(), buffered.getHeight());
hsv.reshape(buffered.getWidth(), buffered.getHeight());
ConvertBufferedImage.convertFrom(buffered, rgb, true);
ColorHsv.rgbToHsv_F32(rgb, hsv);
Planar<GrayF32> hs = hsv.partialSpectrum(0,1);
// The number of bins is an important parameter. Try adjusting it
Histogram_F64 histogram = new Histogram_F64(12,12);
histogram.setRange(0, 0, 2.0 * Math.PI); // range of hue is from 0 to 2PI
histogram.setRange(1, 0, 1.0); // range of saturation is from 0 to 1
// Compute the histogram
GHistogramFeatureOps.histogram(hs,histogram);
UtilFeature.normalizeL2(histogram); // normalize so that image size doesn't matter
return histogram.value;
}