use of boofcv.struct.image.ImageGray in project BoofCV by lessthanoptimal.
the class OrientationHistogramSift method computeHistogram.
/**
* Constructs the histogram around the specified point.
*
* @param c_x Center x-axis
* @param c_y Center y-axis
* @param sigma Scale of feature, adjusted for local octave
*/
void computeHistogram(int c_x, int c_y, double sigma) {
int r = (int) Math.ceil(sigma * sigmaEnlarge);
// specify the area being sampled
bound.x0 = c_x - r;
bound.y0 = c_y - r;
bound.x1 = c_x + r + 1;
bound.y1 = c_y + r + 1;
ImageGray rawDX = derivX.getImage();
ImageGray rawDY = derivY.getImage();
// make sure it is contained in the image bounds
BoofMiscOps.boundRectangleInside(rawDX, bound);
// clear the histogram
Arrays.fill(histogramMag, 0);
Arrays.fill(histogramX, 0);
Arrays.fill(histogramY, 0);
// construct the histogram
for (int y = bound.y0; y < bound.y1; y++) {
// iterate through the raw array for speed
int indexDX = rawDX.startIndex + y * rawDX.stride + bound.x0;
int indexDY = rawDY.startIndex + y * rawDY.stride + bound.x0;
for (int x = bound.x0; x < bound.x1; x++) {
float dx = derivX.getF(indexDX++);
float dy = derivY.getF(indexDY++);
// edge intensity and angle
double magnitude = Math.sqrt(dx * dx + dy * dy);
double theta = UtilAngle.domain2PI(Math.atan2(dy, dx));
// weight from gaussian
double weight = computeWeight(x - c_x, y - c_y, sigma);
// histogram index
int h = (int) (theta / histAngleBin) % histogramMag.length;
// update the histogram
histogramMag[h] += magnitude * weight;
histogramX[h] += dx * weight;
histogramY[h] += dy * weight;
}
}
}
use of boofcv.struct.image.ImageGray in project BoofCV by lessthanoptimal.
the class TestGlobalEntropyBinaryFilter method compare.
@Test
public void compare() {
Class[] imageTypes = new Class[] { GrayU8.class, GrayF32.class };
for (Class type : imageTypes) {
ImageGray input = GeneralizedImageOps.createSingleBand(type, 30, 40);
GrayU8 found = new GrayU8(30, 40);
GrayU8 expected = new GrayU8(30, 40);
GImageMiscOps.fillUniform(input, rand, 0, 200);
GlobalEntropyBinaryFilter alg = new GlobalEntropyBinaryFilter(0, 255, true, ImageType.single(type));
alg.process(input, found);
double threshold = GThresholdImageOps.computeEntropy(input, 0, 255);
GThresholdImageOps.threshold(input, expected, threshold, true);
BoofTesting.assertEquals(found, expected, 0);
}
}
use of boofcv.struct.image.ImageGray in project BoofCV by lessthanoptimal.
the class TestGlobalFixedBinaryFilter method compare.
@Test
public void compare() {
Class[] imageTypes = new Class[] { GrayU8.class, GrayF32.class };
for (Class type : imageTypes) {
ImageGray input = GeneralizedImageOps.createSingleBand(type, 30, 40);
GrayU8 found = new GrayU8(30, 40);
GrayU8 expected = new GrayU8(30, 40);
GImageMiscOps.fillUniform(input, rand, 0, 200);
GlobalFixedBinaryFilter alg = new GlobalFixedBinaryFilter(120, true, ImageType.single(type));
alg.process(input, found);
GThresholdImageOps.threshold(input, expected, 120, true);
BoofTesting.assertEquals(found, expected, 0);
}
}
use of boofcv.struct.image.ImageGray in project BoofCV by lessthanoptimal.
the class TestLocalGaussianBinaryFilter method compare.
@Test
public void compare() {
Class[] imageTypes = new Class[] { GrayU8.class, GrayF32.class };
for (Class type : imageTypes) {
ImageGray input = GeneralizedImageOps.createSingleBand(type, 30, 40);
GrayU8 found = new GrayU8(30, 40);
GrayU8 expected = new GrayU8(30, 40);
GImageMiscOps.fillUniform(input, rand, 0, 200);
LocalGaussianBinaryFilter alg = new LocalGaussianBinaryFilter(ConfigLength.fixed(9), 0.95, true, ImageType.single(type));
alg.process(input, found);
GThresholdImageOps.localGaussian(input, expected, ConfigLength.fixed(9), 0.95, true, null, null);
BoofTesting.assertEquals(found, expected, 0);
}
}
use of boofcv.struct.image.ImageGray in project BoofCV by lessthanoptimal.
the class TestLocalMeanBinaryFilter method compare.
@Test
public void compare() {
Class[] imageTypes = new Class[] { GrayU8.class, GrayF32.class };
for (Class type : imageTypes) {
ImageGray input = GeneralizedImageOps.createSingleBand(type, 30, 40);
GrayU8 found = new GrayU8(30, 40);
GrayU8 expected = new GrayU8(30, 40);
GImageMiscOps.fillUniform(input, rand, 0, 200);
LocalMeanBinaryFilter alg = new LocalMeanBinaryFilter(ConfigLength.fixed(9), 0.95, true, ImageType.single(type));
alg.process(input, found);
GThresholdImageOps.localMean(input, expected, ConfigLength.fixed(9), 0.95, true, null, null);
BoofTesting.assertEquals(found, expected, 0);
}
}
Aggregations