use of boofcv.struct.image.GrayI in project BoofCV by lessthanoptimal.
the class ImageBorderWrapped method wrap.
/**
* Creates an ImageBorder for the two specified images. The offsets are created by dividing the difference
* inside by 2. Border must be bigger the image.
*/
public static <T extends ImageGray<T>> ImageBorder<T> wrap(T border, T image) {
int offsetX = (border.width - image.width) / 2;
int offsetY = (border.height - image.height) / 2;
ImageBorder<T> ret;
if (border instanceof GrayI) {
ret = new S32(offsetX, offsetY, (GrayI) border);
} else if (border instanceof GrayF32) {
ret = (ImageBorder) new F32(offsetX, offsetY, (GrayF32) border);
} else {
throw new RuntimeException("Not supported yet");
}
ret.setImage(image);
return ret;
}
use of boofcv.struct.image.GrayI in project BoofCV by lessthanoptimal.
the class TestEnhanceImageOps method equalizeLocal.
public void equalizeLocal(GrayI input, GrayI found) {
GrayI expected = (GrayI) GeneralizedImageOps.createSingleBand(input.getClass(), input.width, input.height);
GImageMiscOps.fillUniform(input, rand, 0, 9);
GrowArray<DogArray_I32> workArrays = new GrowArray<>(DogArray_I32::new);
for (int radius = 1; radius < 11; radius++) {
BoofTesting.callStaticMethod(ImplEnhanceHistogram.class, "equalizeLocalNaive", input, radius, histogramLength, expected, workArrays);
BoofTesting.callStaticMethod(EnhanceImageOps.class, "equalizeLocal", input, radius, found, histogramLength, workArrays);
BoofTesting.assertEquals(expected, found, 1e-10);
}
}
use of boofcv.struct.image.GrayI in project BoofCV by lessthanoptimal.
the class TestEnhanceImageOps method equalizeLocal.
@Test
void equalizeLocal() {
int numFound = 0;
Method[] methods = EnhanceImageOps.class.getMethods();
for (int i = 0; i < methods.length; i++) {
if (methods[i].getName().compareTo("equalizeLocal") != 0)
continue;
numFound++;
Class imageType = methods[i].getParameterTypes()[0];
GrayI input = (GrayI) GeneralizedImageOps.createSingleBand(imageType, width, height);
GrayI output = (GrayI) GeneralizedImageOps.createSingleBand(imageType, width, height);
equalizeLocal(input, output);
BoofTesting.checkSubImage(this, "equalizeLocal", true, input, output);
}
assertEquals(2, numFound);
}
use of boofcv.struct.image.GrayI in project BoofCV by lessthanoptimal.
the class TestImplEnhanceHistogram method equalizeLocalInner.
@Test
void equalizeLocalInner() {
int numFound = 0;
Method[] methods = ImplEnhanceHistogram.class.getMethods();
for (Method method : methods) {
if (method.getName().compareTo("equalizeLocalNaive") != 0)
continue;
numFound++;
Class imageType = method.getParameterTypes()[0];
GrayI input = (GrayI) GeneralizedImageOps.createSingleBand(imageType, width, height);
GrayI output = (GrayI) GeneralizedImageOps.createSingleBand(imageType, width, height);
equalizeLocalInner(input, output);
BoofTesting.checkSubImage(this, "equalizeLocalInner", true, input, output);
}
assertEquals(2, numFound);
}
use of boofcv.struct.image.GrayI in project BoofCV by lessthanoptimal.
the class TestImplEnhanceHistogram method equalizeLocalRow.
public void equalizeLocalRow(GrayI input, GrayI found) {
GrayI expected = GeneralizedImageOps.createSingleBand(input.getClass(), input.width, input.height);
GrowArray<DogArray_I32> workArrays = new GrowArray<>(DogArray_I32::new);
GImageMiscOps.fillUniform(input, rand, 0, 9);
// check the top row
for (int radius = 1; radius < 6; radius++) {
// fill with zeros so it can be tested using checkBorderZero
GImageMiscOps.fill(found, 0);
BoofTesting.callStaticMethod(ImplEnhanceHistogram.class, "equalizeLocalNaive", input, radius, histogramLength, expected, workArrays);
BoofTesting.callStaticMethod(ImplEnhanceHistogram.class, "equalizeLocalRow", input, radius, histogramLength, 0, found, workArrays);
GrayI subExpected = (GrayI) expected.subimage(0, 0, width, radius, null);
GrayI subFound = (GrayI) found.subimage(0, 0, width, radius, null);
// check solution
BoofTesting.assertEquals(subExpected, subFound, 1e-10);
checkZeroOutsideRows(found, 0, radius);
}
// check the bottom row
for (int radius = 1; radius < 6; radius++) {
// fill with zeros so it can be tested using checkBorderZero
GImageMiscOps.fill(found, 0);
int start = input.height - radius;
BoofTesting.callStaticMethod(ImplEnhanceHistogram.class, "equalizeLocalNaive", input, radius, histogramLength, expected, workArrays);
BoofTesting.callStaticMethod(ImplEnhanceHistogram.class, "equalizeLocalRow", input, radius, histogramLength, start, found, workArrays);
GrayI subExpected = (GrayI) expected.subimage(0, start, width, height, null);
GrayI subFound = (GrayI) found.subimage(0, start, width, height, null);
// check solution
BoofTesting.assertEquals(subExpected, subFound, 1e-10);
checkZeroOutsideRows(found, start, height);
}
}
Aggregations