当前位置: 首页>>代码示例>>Java>>正文


Java GrayU8.getWidth方法代码示例

本文整理汇总了Java中boofcv.struct.image.GrayU8.getWidth方法的典型用法代码示例。如果您正苦于以下问题:Java GrayU8.getWidth方法的具体用法?Java GrayU8.getWidth怎么用?Java GrayU8.getWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在boofcv.struct.image.GrayU8的用法示例。


在下文中一共展示了GrayU8.getWidth方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: binaryToDrawable

import boofcv.struct.image.GrayU8; //导入方法依赖的package包/类
public static GrayU8 binaryToDrawable(GrayU8 image) {
    GrayU8 drawable = new GrayU8(image.width,image.height);
    for (int y=0;y<image.getHeight();y++) {
        for (int x = 0; x < image.getWidth(); x++) {
            if (image.get(x, y) > 0) {
                drawable.set(x, y, BLACK);
            } else {
                drawable.set(x, y, WHITE);
            }
        }
    }
    return drawable;
}
 
开发者ID:ftomassetti,项目名称:SketchModel,代码行数:14,代码来源:Drawing.java

示例2: process

import boofcv.struct.image.GrayU8; //导入方法依赖的package包/类
protected static float[] process(MultiImage img, float[] hist) {
  GrayU8 gray = ConvertBufferedImage.convertFrom(img.getBufferedImage(), (GrayU8) null);
  int width = img.getWidth(), height = img.getHeight();
  for (int x = 0; x < 4; ++x) {
    for (int y = 0; y < 4; ++y) {
      GrayU8 subImage = gray
          .subimage(width * x / 4, height * y / 4, width * (x + 1) / 4, height * (y + 1) / 4,
              null);
      int count = 0;
      int[] tmp = new int[5];
      for (int xx = 0; xx < subImage.getWidth() - 1; xx += 2) {
        for (int yy = 0; yy < subImage.getHeight() - 1; yy += 2) {
          count++;
          int index = edgeType(
              subImage.unsafe_get(xx, yy),
              subImage.unsafe_get(xx + 1, yy),
              subImage.unsafe_get(xx, yy + 1),
              subImage.unsafe_get(xx + 1, yy + 1)
          );
          if (index > -1) {
            tmp[index]++;
          }
        }
      }
      int offset = (4 * x + y) * 5;
      for (int i = 0; i < 5; ++i) {
        hist[offset + i] += ((float) tmp[i]) / (float) count;
      }
    }
  }
  return hist;
}
 
开发者ID:vitrivr,项目名称:cineast,代码行数:33,代码来源:EHD.java

示例3: derivateCleanser

import boofcv.struct.image.GrayU8; //导入方法依赖的package包/类
/**
 * Consider only the points with strong derivates and remove the rest.
 */
private GrayU8 derivateCleanser( GrayU8 input ) {
    int blurRadius = 5;

    imageShower.show(input,"Derivates Input");

    GrayU8 blurred = new GrayU8(input.width,input.height);
    GrayS16 derivX = new GrayS16(input.width,input.height);
    GrayS16 derivY = new GrayS16(input.width,input.height);

    // Gaussian blur: Convolve a Gaussian kernel
    BlurImageOps.gaussian(input,blurred,-1,blurRadius,null);

    logTime("derivateCleanser a");

    // Calculate image's derivative
    GradientSobel.process(blurred, derivX, derivY, FactoryImageBorderAlgs.extend(input));

    logTime("derivateCleanser b");

    // First I save on a matrix if the point has a strong derivative
    int derivThreshold = 100;
    Map<Point, Boolean> pointsWithStrongDerivates = new HashMap<>();
    for (int y=0; y<input.getHeight(); y++) {
        for (int x=0; x<input.getWidth(); x++) {
            int dx = derivX.get(x, y);
            int dy = derivY.get(x, y);
            int totalDeriv = Math.abs(dx) + Math.abs(dy);
            if (totalDeriv > derivThreshold) {
                pointsWithStrongDerivates.put(new Point(x, y), true);
            }
        }
    }

    logTime("derivateCleanser c");

    // Second: I remove points with strong derivatives if they have not enough other points with strong derivates
    //         near them
    GrayU8 pointsToKeep = removeIsolatedPoints(pointsWithStrongDerivates, input.getWidth(), input.getHeight());

    logTime("derivateCleanser d");
    imageShower.show(pointsToKeep,"Derivates pointsToKeep");

    // display the results
    if (imageShower.verbose()) {
        BufferedImage outputImage = VisualizeImageData.colorizeGradient(derivX, derivY, -1);
        imageShower.show(outputImage, "Derivates");
    }
    imageShower.show(input,"Derivates Cleansed");
    imageShower.show(input,"Derivates Output");

    logTime("derivateCleanser e");

    return pointsToKeep;
}
 
开发者ID:ftomassetti,项目名称:SketchModel,代码行数:58,代码来源:ModelBuilder.java


注:本文中的boofcv.struct.image.GrayU8.getWidth方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。