Esempio n. 1
0
    def test_shrink_image(self):
        # Just test to see if it crashes
        j_img = pb.create_single_band(100, 120, dtype=np.uint8)

        # ---------- Single axis specified
        # Shrink with integration
        found = pb.shrink_image(j_img,
                                60,
                                interp_type=pb.InterpolationType.INTEGRAL)
        self.assertEqual(60 * 100 / 120, found.getWidth())
        self.assertEqual(60 * 120 / 120, found.getHeight())

        # Shrink with interpolation
        found = pb.shrink_image(j_img,
                                60,
                                interp_type=pb.InterpolationType.BILINEAR)
        self.assertEqual(60 * 100 / 120, found.getWidth())
        self.assertEqual(60 * 120 / 120, found.getHeight())

        # ---------- Both axises specified
        # Shrink with integration
        found = pb.shrink_image(j_img, (50, 60),
                                interp_type=pb.InterpolationType.INTEGRAL)
        self.assertEqual(60, found.getWidth())
        self.assertEqual(50, found.getHeight())

        # Shrink with interpolation
        found = pb.shrink_image(j_img, (50, 60),
                                interp_type=pb.InterpolationType.BILINEAR)
        self.assertEqual(60, found.getWidth())
        self.assertEqual(50, found.getHeight())
Esempio n. 2
0
    def test_array_write_gray(self):
        for dtype in self.dtypes:
            j_img = pb.create_single_band(100, 120, dtype=dtype)
            b_image = pb.BImage(j_img)

            b_image[2, 3] = 5

            self.assertEqual(5, j_img.get(3, 2))
Esempio n. 3
0
    def test_createHog(self):
        j_img = pb.create_single_band(100, 120, dtype=np.uint8)

        factory = pb.FactoryDenseDescribe(dtype=np.uint8)
        describer = factory.createHoG(None)
        describer.detect(j_img)
        self.assertTrue(len(describer.locations) > 10)
        self.assertTrue(len(describer.descriptions) > 10)
Esempio n. 4
0
    def test_createSurf_stable(self):
        j_img = pb.create_single_band(100, 120, dtype=np.uint8)

        factory = pb.FactoryDenseDescribe(dtype=np.uint8)
        describer = factory.createSurf(pb.ConfigDenseSurfStable())
        describer.detect(j_img)
        self.assertTrue(len(describer.locations) > 10)
        self.assertTrue(len(describer.descriptions) > 10)
Esempio n. 5
0
    def test_mmap_boof_to_numpy_F32(self):
        pb_img = pb.create_single_band(100, 120, dtype=np.float32)
        pb.fill_uniform(pb_img, -2, 2)
        np_img = pb.mmap_boof_to_numpy_F32(pb_img)

        self.assertEqual(np_img.dtype, np.float32)
        self.assertEqual(np_img.shape[0], pb_img.getHeight())
        self.assertEqual(np_img.shape[1], pb_img.getWidth())

        self.assertAlmostEqual(np_img[0, 0], pb_img.get(0, 0))
        self.assertAlmostEqual(np_img[20, 10], pb_img.get(10, 20))
Esempio n. 6
0
#!/usr/bin/env python3

import numpy as np

import pyboof as pb

original = pb.load_single_band(
    '../data/example/fiducial/image/examples/image00.jpg', np.uint8)

binary = pb.create_single_band(original.getWidth(), original.getHeight(),
                               np.uint8)

algorithms = []

factory = pb.FactoryThresholdBinary(np.uint8)

algorithms.append(("localGaussian", factory.localGaussian(region_width=11)))
algorithms.append(("localSauvola", factory.localSauvola(region_width=11)))
algorithms.append(("localMean", factory.localMean(region_width=11)))
algorithms.append(("localNick", factory.localNick(region_width=11)))
# algorithms.append(("localOtsu"  ,factory.localOtsu(region_width=11))) # This can be slow
algorithms.append(("blockMinMax", factory.blockMinMax(region_width=11)))
algorithms.append(("blockMean", factory.blockMean(region_width=11)))
algorithms.append(("blockOtsu", factory.blockOtsu(region_width=11)))
algorithms.append(("globalEntropy", factory.globalEntropy()))
algorithms.append(("globalOtsu", factory.globalOtsu()))
algorithms.append(("globalLi", factory.globalLi()))
algorithms.append(("globalHuang", factory.globalHuang()))
algorithms.append(("globalFixed", factory.globalFixed(threshold=100)))

image_list = [(original, "Original")]
Esempio n. 7
0
 def test_shape_gray(self):
     j_img = pb.create_single_band(100, 120, dtype=np.uint8)
     found = pb.BImage(j_img).shape
     self.assertEqual(2, len(found))
     self.assertEqual(120, found[0])
     self.assertEqual(100, found[1])
Esempio n. 8
0
 def test_property_reading(self):
     j_img = pb.create_single_band(100, 120, dtype=np.uint8)
     b_image = pb.BImage(j_img)
     self.assertEqual(100, b_image.width)
     self.assertEqual(120, b_image.height)
import numpy as np

import pyboof as pb

original = pb.load_single_band('../data/example/fiducial/image/examples/image00.jpg',np.uint8)

binary = pb.create_single_band(original.getWidth(),original.getHeight(),np.uint8)

algorithms = []

factory = pb.FactoryThresholdBinary(np.uint8)

algorithms.append(("localGaussian",factory.localGaussian(radius=5)))
algorithms.append(("localSauvola" ,factory.localSauvola(radius=5)))
algorithms.append(("localSquare"  ,factory.localSquare(radius=5)))
algorithms.append(("globalEntropy",factory.globalEntropy()))
algorithms.append(("globalOtsu"   ,factory.globalOtsu()))
algorithms.append(("globalFixed"  ,factory.globalFixed(threshold=100)))

image_list = [(original, "Original")]

for a in algorithms:
    a[1].process(original, binary)
    buffered_binary = pb.swing.render_binary(binary)
    image_list.append((buffered_binary,a[0]))

pb.swing.show_list(image_list, title="Binary Thresholding")

raw_input("Press any key to exit")
Esempio n. 10
0
#!/usr/bin/env python3

import numpy as np

import pyboof as pb

original = pb.load_single_band('../data/example/outdoors01.jpg', np.uint8)

# Let BoofCV decide on the type of image to store the gradient as
deriv_dtype = pb.gradient_dtype(pb.get_dtype(original))

# Declare the gradient images
derivX = pb.create_single_band(original.getWidth(), original.getHeight(),
                               deriv_dtype)
derivY = pb.create_single_band(original.getWidth(), original.getHeight(),
                               deriv_dtype)

# Compute the results for a few operators and visualize
pb.gradient(original, derivX, derivY, pb.GradientType.SOBEL)
buffered_sobel = pb.swing.colorize_gradient(derivX, derivY)

pb.gradient(original, derivX, derivY, pb.GradientType.PREWITT)
buffered_prewitt = pb.swing.colorize_gradient(derivX, derivY)

pb.gradient(original, derivX, derivY, pb.GradientType.SCHARR)
buffered_pscharr = pb.swing.colorize_gradient(derivX, derivY)

pb.gradient(original, derivX, derivY, pb.GradientType.THREE)
buffered_three = pb.swing.colorize_gradient(derivX, derivY)

pb.gradient(original, derivX, derivY, pb.GradientType.TWO0)
Esempio n. 11
0
import pyboof as pb

import numpy as np

original = pb.load_single_band('../../../data/applet/outdoors01.jpg',np.uint8)

# Let BoofCV decide on the type of image to store the gradient as
deriv_dtype = pb.gradient_dtype(pb.get_dtype(original))

# Declare the gradient images
derivX = pb.create_single_band(original.getWidth(),original.getHeight(),deriv_dtype)
derivY = pb.create_single_band(original.getWidth(),original.getHeight(),deriv_dtype)

# Compute the results for a few operators and visualize
pb.gradient(original,derivX,derivY,pb.GradientType.SOBEL)
buffered_sobel = pb.swing.colorize_gradient(derivX,derivY)

pb.gradient(original,derivX,derivY,pb.GradientType.PREWITT)
buffered_prewitt = pb.swing.colorize_gradient(derivX,derivY)

pb.gradient(original,derivX,derivY,pb.GradientType.THREE)
buffered_three = pb.swing.colorize_gradient(derivX,derivY)

pb.gradient(original,derivX,derivY,pb.GradientType.TWO0)
buffered_two0 = pb.swing.colorize_gradient(derivX,derivY)

pb.gradient(original,derivX,derivY,pb.GradientType.TWO1)
buffered_two1 = pb.swing.colorize_gradient(derivX,derivY)

# display the results in a single window as a list
image_list = [(original,"original"),