Search in sources :

Example 6 with Tensor_F32

use of deepboof.tensors.Tensor_F32 in project BoofCV by lessthanoptimal.

the class TestDataManipulationOps method imageToTensor.

@Test
public void imageToTensor() {
    Planar<GrayF32> image = new Planar<>(GrayF32.class, 30, 25, 2);
    GImageMiscOps.fillUniform(image, rand, -2, 2);
    Tensor_F32 tensor = new Tensor_F32(1, 2, 25, 30);
    DataManipulationOps.imageToTensor(image, tensor, 0);
    for (int band = 0; band < image.bands.length; band++) {
        for (int i = 0; i < image.height; i++) {
            for (int j = 0; j < image.width; j++) {
                assertEquals(image.getBand(band).get(j, i), tensor.get(0, band, i, j), 1e-4f);
            }
        }
    }
}
Also used : GrayF32(boofcv.struct.image.GrayF32) Planar(boofcv.struct.image.Planar) Tensor_F32(deepboof.tensors.Tensor_F32) Test(org.junit.Test)

Aggregations

Tensor_F32 (deepboof.tensors.Tensor_F32)6 Function (deepboof.Function)4 GrayF32 (boofcv.struct.image.GrayF32)3 ParseBinaryTorch7 (deepboof.io.torch7.ParseBinaryTorch7)3 File (java.io.File)3 Planar (boofcv.struct.image.Planar)2 Test (org.junit.Test)2 BorderType (boofcv.core.image.border.BorderType)1 Node (deepboof.graph.Node)1 FunctionLinear_F32 (deepboof.impl.forward.standard.FunctionLinear_F32)1 ParseAsciiTorch7 (deepboof.io.torch7.ParseAsciiTorch7)1 TorchGeneric (deepboof.io.torch7.struct.TorchGeneric)1 TorchObject (deepboof.io.torch7.struct.TorchObject)1 ArrayList (java.util.ArrayList)1