本文整理汇总了Java中boofcv.struct.image.ImageFloat32.get方法的典型用法代码示例。如果您正苦于以下问题:Java ImageFloat32.get方法的具体用法?Java ImageFloat32.get怎么用?Java ImageFloat32.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boofcv.struct.image.ImageFloat32
的用法示例。
在下文中一共展示了ImageFloat32.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: refineSubpixel
import boofcv.struct.image.ImageFloat32; //导入方法依赖的package包/类
/**
* Computes a feature location to sub-pixel accuracy by fitting a 2D quadratic polynomial
* to corner intensities.
* <p/>
* Through experimentation the mean instead of a quadratic fit was found to produce a better
* result. Most papers seem to recommend using the quadratic.
*
* @param pt Point in image coordinates
* @param x0 intensity image x offset
* @param y0 intensity image y offset
* @param intensity Intensity image
* @return Sub-pixel point location
*/
private Point2D_F64 refineSubpixel(Point2D_F64 pt,
int x0, int y0,
ImageFloat32 intensity) {
int r = radius + 3;
ImageRectangle area = new ImageRectangle((int) (pt.x - r - x0), (int) (pt.y - r - y0),
(int) (pt.x + r - x0 + 1), (int) (pt.y + r + 1 - y0));
BoofMiscOps.boundRectangleInside(intensity, area);
// sample feature intensity values in the local region
float meanX = 0, meanY = 0, sum = 0;
for (int i = area.y0; i < area.y1; i++) {
for (int j = area.x0; j < area.x1; j++) {
float value = intensity.get(j, i);
meanX += j * value;
meanY += i * value;
sum += value;
}
}
meanX /= sum;
meanY /= sum;
return new Point2D_F64(x0 + meanX, y0 + meanY);
}
示例2: selectBrightest
import boofcv.struct.image.ImageFloat32; //导入方法依赖的package包/类
/**
* Out of the remaining points, just select the brightest to remove any remaining false positives
*/
private List<Point2D_F64> selectBrightest(List<Point2D_F64> points, ImageFloat32 intensity,
int offX, int offY) {
if (points.size() == expectedPoints)
return points;
double values[] = new double[points.size()];
int indexes[] = new int[points.size()];
for (int i = 0; i < points.size(); i++) {
Point2D_F64 p = points.get(i);
values[i] = -intensity.get((int) (p.x - offX), (int) (p.y - offY));
}
new QuickSort_F64().sort(values, points.size(), indexes);
List<Point2D_F64> ret = new ArrayList<Point2D_F64>();
for (int i = 0; i < expectedPoints; i++) {
ret.add(points.get(indexes[i]));
}
return ret;
}
示例3: negativeCase
import boofcv.struct.image.ImageFloat32; //导入方法依赖的package包/类
@Test
public void negativeCase() {
GImageMiscOps.fillUniform(image, rand, 0, 200);
alg.process(image, template);
if (isPerfectZero) {
// there should be no perfect matches
int x0 = alg.getOffsetX();
int x1 = image.width - (template.width - x0);
int y0 = alg.getOffsetY();
int y1 = image.width - (template.width - x0);
ImageFloat32 intensity = alg.getIntensity();
for (int y = y0; y < y1; y++) {
for (int x = x0; x < x1; x++) {
if (intensity.get(x, y) == 0)
fail("There should be no perfect matches");
}
}
}
}
示例4: process
import boofcv.struct.image.ImageFloat32; //导入方法依赖的package包/类
/**
* Computes the derivative of 'orig' along the x and y axes
*/
public static void process( ImageFloat32 orig,
ImageFloat32 derivX,
ImageFloat32 derivY) {
final int width = orig.getWidth();
final int height = orig.getHeight();
for (int y = 1; y < height - 1; y++) {
for (int x = 1; x < width - 1; x++) {
float dy = -(orig.get(x - 1, y - 1) * 0.25F + orig.get(x, y - 1) * 0.5F + orig.get(x + 1, y - 1) * 0.25F);
dy += (orig.get(x - 1, y + 1) * 0.25F + orig.get(x, y + 1) * 0.5F + orig.get(x + 1, y + 1) * 0.25F);
float dx = -(orig.get(x - 1, y - 1) * 0.25F + orig.get(x - 1, y) * 0.5F + orig.get(x - 1, y + 1) * 0.25F);
dx += (orig.get(x + 1, y - 1) * 0.25F + orig.get(x + 1, y) * 0.5F + orig.get(x + 1, y + 1) * 0.25F);
derivX.set(x, y, dx);
derivY.set(x, y, dy);
}
}
}
示例5: basicTest
import boofcv.struct.image.ImageFloat32; //导入方法依赖的package包/类
/**
* Basis tests to see if it computes the expected pyramid
*/
@Test
public void basicTest() {
ImageFloat32 input = new ImageFloat32(40,80);
ImageMiscOps.fillUniform(input, rand, -20, 50);
PyramidDiscreteAverage<ImageFloat32> alg = new PyramidDiscreteAverage<ImageFloat32>(ImageFloat32.class,true,1,2,4);
alg.process(input);
// request was made use a reference to the input image
assertTrue(input == alg.getLayer(0));
float expected = (input.get(0,0) + input.get(0,1) + input.get(1,0) + input.get(1,1))/4;
assertEquals(expected,alg.getLayer(1).get(0,0),1e-4);
ImageFloat32 layer = alg.getLayer(1);
expected = (layer.get(0,0) + layer.get(0,1) + layer.get(1,0) + layer.get(1,1))/4;
assertEquals(expected,alg.getLayer(2).get(0,0),1e-4);
}
示例6: scaleSanityCheck
import boofcv.struct.image.ImageFloat32; //导入方法依赖的package包/类
@Test
public void scaleSanityCheck() {
ImageFloat32 input = new ImageFloat32(width,height);
ImageFloat32 output = new ImageFloat32(width/2,height/2);
GImageMiscOps.fillUniform(input, rand, 0, 100);
DistortImageOps.scale(input, output, TypeInterpolate.BILINEAR);
double error = 0;
for( int y = 0; y < output.height; y++ ) {
for( int x = 0; x < output.width; x++ ) {
double e = input.get(x*2,y*2)-output.get(x,y);
error += Math.abs(e);
}
}
assertTrue(error / (output.width * output.height) < 0.1);
}
示例7: rotate_SanityCheck
import boofcv.struct.image.ImageFloat32; //导入方法依赖的package包/类
/**
* Very simple test for rotation accuracy.
*/
@Test
public void rotate_SanityCheck() {
ImageFloat32 input = new ImageFloat32(width,height);
ImageFloat32 output = new ImageFloat32(height,width);
GImageMiscOps.fillUniform(input, rand, 0, 100);
DistortImageOps.rotate(input, output, TypeInterpolate.BILINEAR, (float) Math.PI / 2f);
double error = 0;
// the outside pixels are ignored because numerical round off can cause those to be skipped
for( int y = 1; y < input.height-1; y++ ) {
for( int x = 1; x < input.width-1; x++ ) {
int xx = output.width-y;
int yy = x;
double e = input.get(x,y)-output.get(xx,yy);
error += Math.abs(e);
}
}
assertTrue(error / (width * height) < 0.1);
}
示例8: computeEdgeMSE
import boofcv.struct.image.ImageFloat32; //导入方法依赖的package包/类
private double computeEdgeMSE(ImageFloat32 imageInv) {
ImageFloat32 edge = new ImageFloat32(imageInv.width,imageInv.height);
LaplacianEdge.process(image,edge);
PixelMath.abs(edge,edge);
float max = ImageStatistics.maxAbs(edge);
PixelMath.divide(edge,max,edge);
float total = ImageStatistics.sum(edge);
double error = 0;
for( int y = 0; y < image.height; y++ ) {
for( int x = 0; x < image.width; x++ ) {
double w = edge.get(x,y)/total;
double e = (image.get(x,y)-imageInv.get(x,y));
error += (e*e)*w;
}
}
return error;
}
示例9: computeWeightedError
import boofcv.struct.image.ImageFloat32; //导入方法依赖的package包/类
public static double computeWeightedError(ImageFloat32 imgA, ImageFloat32 imgB ,
ImageFloat32 imgWeight ) {
final int h = imgA.getHeight();
final int w = imgA.getWidth();
double total = 0;
double totalWeight = 0;
for (int y = 0; y < h; y++) {
for (int x = 0; x < w; x++) {
float weight = imgWeight.get(x,y);
double difference = Math.abs(imgA.get(x,y)-imgB.get(x,y));
total += difference*weight;
totalWeight += weight;
}
}
return total / totalWeight;
}
示例10: findLocalScaleSpaceMax
import boofcv.struct.image.ImageFloat32; //导入方法依赖的package包/类
/**
* Searches the pyramid layers up and down to see if the found 2D features are also scale space maximums.
*/
protected void findLocalScaleSpaceMax(PyramidFloat<T> ss, int layerID) {
int index0 = spaceIndex;
int index1 = (spaceIndex + 1) % 3;
int index2 = (spaceIndex + 2) % 3;
List<Point2D_I16> candidates = maximums[index1];
ImageBorder_F32 inten0 = (ImageBorder_F32) FactoryImageBorderAlgs.value(intensities[index0], 0);
ImageFloat32 inten1 = intensities[index1];
ImageBorder_F32 inten2 = (ImageBorder_F32) FactoryImageBorderAlgs.value(intensities[index2], 0);
float scale0 = (float) ss.scale[layerID - 1];
float scale1 = (float) ss.scale[layerID];
float scale2 = (float) ss.scale[layerID + 1];
float sigma0 = (float) ss.getSigma(layerID - 1);
float sigma1 = (float) ss.getSigma(layerID);
float sigma2 = (float) ss.getSigma(layerID + 1);
// not sure if this is the correct way to handle the change in scale
float ss0 = (float) (Math.pow(sigma0, scalePower)/scale0);
float ss1 = (float) (Math.pow(sigma1, scalePower)/scale1);
float ss2 = (float) (Math.pow(sigma2, scalePower)/scale2);
for (Point2D_I16 c : candidates) {
float val = ss1 * inten1.get(c.x, c.y);
// find pixel location in each image's local coordinate
int x0 = (int) (c.x * scale1 / scale0);
int y0 = (int) (c.y * scale1 / scale0);
int x2 = (int) (c.x * scale1 / scale2);
int y2 = (int) (c.y * scale1 / scale2);
if (checkMax(inten0, val / ss0, x0, y0) && checkMax(inten2, val / ss2, x2, y2)) {
// put features into the scale of the upper image
foundPoints.add(new ScalePoint(c.x * scale1, c.y * scale1, sigma1));
}
}
}
示例11: sum
import boofcv.struct.image.ImageFloat32; //导入方法依赖的package包/类
public float sum( int x , int y , ImageFloat32 img ) {
float ret = 0;
for( int i = -radius; i <= radius; i++ ) {
float hsum = 0;
for( int j = -radius; j <= radius; j++ ) {
hsum += img.get(j+x,i+y);
}
ret += hsum;
}
return ret;
}
示例12: checkInner
import boofcv.struct.image.ImageFloat32; //导入方法依赖的package包/类
public void checkInner( ImageFloat32 image , int c_x , int c_y , int w , int h ) {
ImplDescribePointPixelRegionNCC_F32 alg = new ImplDescribePointPixelRegionNCC_F32(w,h);
NccFeature desc = new NccFeature(alg.getDescriptorLength());
alg.setImage(image);
assertTrue(alg.isInBounds(c_x, c_y));
alg.process(c_x, c_y, desc);
int y0 = c_y-h/2;
int x0 = c_x-w/2;
double mean = 0;
for( int y = y0; y < y0+h; y++ ) {
for( int x = x0; x < x0+w; x++ ) {
mean += image.get(x,y);
}
}
mean /= w*h;
double variance = 0;
for( int y = y0; y < y0+h; y++ ) {
for( int x = x0; x < x0+w; x++ ) {
double a = image.get(x,y) - mean;
variance += a*a;
}
}
variance /= w*h;
assertEquals(desc.mean,mean,1e-8);
assertEquals(desc.sigma,Math.sqrt(variance),1e-8);
int index = 0;
for( int y = y0; y < y0+h; y++ ) {
for( int x = x0; x < x0+w; x++ , index++ ) {
assertEquals(image.get(x,y)-mean,desc.value[index],1e-4);
}
}
}
示例13: process
import boofcv.struct.image.ImageFloat32; //导入方法依赖的package包/类
/**
* Performs a median filter.
*
* @param input Raw input image.
* @param output Filtered image.
* @param radius Size of the filter's region.
* @param storage Array used for storage. If null a new array is declared internally.
*/
public static void process(ImageFloat32 input, ImageFloat32 output, int radius , float[] storage ) {
int w = 2*radius+1;
if( storage == null ) {
storage = new float[ w*w ];
} else if( storage.length < w*w ) {
throw new IllegalArgumentException("'storage' must be at least of length "+(w*w));
}
for( int y = 0; y < input.height; y++ ) {
int minI = y - radius;
int maxI = y + radius+1;
// bound the y-axius inside the image
if( minI < 0 ) minI = 0;
if( maxI > input.height ) maxI = input.height;
for( int x = 0; x < input.width; x++ ) {
int minJ = x - radius;
int maxJ = x + radius+1;
// bound the x-axis to be inside the image
if( minJ < 0 ) minJ = 0;
if( maxJ > input.width ) maxJ = input.width;
int index = 0;
for( int i = minI; i < maxI; i++ ) {
for( int j = minJ; j < maxJ; j++ ) {
storage[index++] = input.get(j,i);
}
}
// use quick select to avoid sorting the whole list
float median = QuickSelectArray.select(storage,index/2,index);
output.set(x,y, median );
}
}
}
示例14: computeExpected
import boofcv.struct.image.ImageFloat32; //导入方法依赖的package包/类
private float computeExpected( ImageFloat32 image ) {
ImageFloat32 temp = new ImageFloat32(image.width,image.height);
ImageFloat32 temp2 = new ImageFloat32(image.width,image.height);
ConvolveNormalized.horizontal(kernelF32,image,temp);
ConvolveNormalized.vertical(kernelF32,temp,temp2);
return temp2.get(targetX,targetY);
}
示例15: computeExpected
import boofcv.struct.image.ImageFloat32; //导入方法依赖的package包/类
private float computeExpected( ImageFloat32 image ) {
ImageFloat32 temp = new ImageFloat32(image.width,image.height);
ImageFloat32 temp2 = new ImageFloat32(image.width,image.height);
ConvolveImageNoBorder.horizontal(kernelF32,image,temp,true);
ConvolveImageNoBorder.vertical(kernelF32,temp,temp2,true);
return temp2.get(targetX,targetY);
}