org.bytedeco.javacpp.indexer.UByteIndexer Java Examples

The following examples show how to use org.bytedeco.javacpp.indexer.UByteIndexer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestImageTransform.java    From DataVec with Apache License 2.0 6 votes vote down vote up
public static ImageWritable makeRandomImage(int height, int width, int channels) {
    if (height <= 0) {
        height = rng.nextInt() % 100 + 200;
    }
    if (width <= 0) {
        width = rng.nextInt() % 100 + 200;
    }
    Mat img = new Mat(height, width, CV_8UC(channels));
    UByteIndexer idx = img.createIndexer();
    for (int i = 0; i < height; i++) {
        for (int j = 0; j < width; j++) {
            for (int k = 0; k < channels; k++) {
                idx.put(i, j, k, rng.nextInt());
            }
        }
    }
    Frame frame = converter.convert(img);
    return new ImageWritable(frame);
}
 
Example #2
Source File: TestNativeImageLoader.java    From DataVec with Apache License 2.0 6 votes vote down vote up
Mat makeRandomImage(int height, int width, int channels) {
    if (height <= 0) {
        height = rng.nextInt() % 100 + 100;
    }
    if (width <= 0) {
        width = rng.nextInt() % 100 + 100;
    }

    Mat img = new Mat(height, width, CV_8UC(channels));
    UByteIndexer idx = img.createIndexer();
    for (int i = 0; i < height; i++) {
        for (int j = 0; j < width; j++) {
            for (int k = 0; k < channels; k++) {
                idx.put(i, j, k, rng.nextInt());
            }
        }
    }
    return img;
}
 
Example #3
Source File: TestImageTransform.java    From deeplearning4j with Apache License 2.0 6 votes vote down vote up
public static ImageWritable makeRandomImage(int height, int width, int channels) {
    if (height <= 0) {
        height = rng.nextInt() % 100 + 200;
    }
    if (width <= 0) {
        width = rng.nextInt() % 100 + 200;
    }
    Mat img = new Mat(height, width, CV_8UC(channels));
    UByteIndexer idx = img.createIndexer();
    for (int i = 0; i < height; i++) {
        for (int j = 0; j < width; j++) {
            for (int k = 0; k < channels; k++) {
                idx.put(i, j, k, rng.nextInt());
            }
        }
    }
    Frame frame = converter.convert(img);
    return new ImageWritable(frame);
}
 
Example #4
Source File: TestNativeImageLoader.java    From deeplearning4j with Apache License 2.0 6 votes vote down vote up
Mat makeRandomImage(int height, int width, int channels) {
    if (height <= 0) {
        height = rng.nextInt() % 100 + 100;
    }
    if (width <= 0) {
        width = rng.nextInt() % 100 + 100;
    }

    Mat img = new Mat(height, width, CV_8UC(channels));
    UByteIndexer idx = img.createIndexer();
    for (int i = 0; i < height; i++) {
        for (int j = 0; j < width; j++) {
            for (int k = 0; k < channels; k++) {
                idx.put(i, j, k, rng.nextInt());
            }
        }
    }
    return img;
}
 
Example #5
Source File: ImageConversionUtils.java    From deeplearning4j with Apache License 2.0 6 votes vote down vote up
public static Mat makeRandomImage(int height, int width, int channels) {
    if (height <= 0) {

        height = new Random().nextInt() % 100 + 100;
    }
    if (width <= 0) {
        width = new Random().nextInt() % 100 + 100;
    }

    Mat img = new Mat(height, width, CV_8UC(channels));
    UByteIndexer idx = img.createIndexer();
    for (int i = 0; i < height; i++) {
        for (int j = 0; j < width; j++) {
            for (int k = 0; k < channels; k++) {
                idx.put(i, j, k, new Random().nextInt());
            }
        }
    }
    return img;
}
 
Example #6
Source File: GeneratorUnitTest.java    From graphicsfuzz with Apache License 2.0 5 votes vote down vote up
@Test
public void testRenderBlackImage() throws Exception {
  final File shaderJobFile = temporaryFolder.newFile("shader.json");
  final ShaderJobFileOperations fileOps = new ShaderJobFileOperations();
  final String shader = "#version 100\n"
      + "precision mediump float;\n"
      + "void main() {\n"
      + "  gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\n"
      + "}\n";
  fileOps.writeShaderJobFile(
      new GlslShaderJob(Optional.empty(), new PipelineInfo(), ParseHelper.parse(shader)),
      shaderJobFile);

  final File image = Util.getImage(shaderJobFile, temporaryFolder, fileOps);
  final Mat mat = opencv_imgcodecs.imread(image.getAbsolutePath());

  final UByteIndexer sI = mat.createIndexer();
  for (int y = 0; y < sI.rows(); y++) {
    for (int x = 0; x < sI.cols(); x++) {
      if ((x % 3) == 2) {
        assertEquals(255, sI.get(y, x));
      } else {
        assertEquals(0, sI.get(y, x));
      }
    }
  }
}
 
Example #7
Source File: DepthAnalysisPImageView.java    From PapARt with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void init() {
        validPointsPImage = papplet.createImage(getWidth(), getHeight(), PConstants.RGB);
        nativeArrayToErode = IplImage.create(getWidth(), getHeight(), IPL_DEPTH_8U, 1);
        erosionIndexer = (UByteIndexer) nativeArrayToErode.createIndexer();
//        validCopy = Arrays.copyOf(depthData.validPointsMask, depthData.validPointsMask.length);
    }