Tabnine Logo
GrayS8
Code IndexAdd Tabnine to your IDE (free)

How to use
GrayS8
in
boofcv.struct.image

Best Java code snippets using boofcv.struct.image.GrayS8 (Showing top 20 results out of 315)

origin: org.boofcv/boofcv-ip

/**
 * Bounds image pixels to be between these two values
 * 
 * @param img Image
 * @param min minimum value.
 * @param max maximum value.
 */
public static void boundImage(GrayS8 img , int min , int max ) {
  final int h = img.getHeight();
  final int w = img.getWidth();
  byte[] data = img.data;
  for (int y = 0; y < h; y++) {
    int index = img.getStartIndex() + y * img.getStride();
    int indexEnd = index+w;
    // for(int x = 0; x < w; x++ ) {
    for (; index < indexEnd; index++) {
      int value = data[index];
      if( value < min )
        data[index] = (byte)min;
      else if( value > max )
        data[index] = (byte)max;
    }
  }
}
origin: org.boofcv/boofcv-ip

/**
 * <p>
 * Converts an {@link boofcv.struct.image.GrayF64} into a {@link boofcv.struct.image.GrayS8}.
 * </p>
 *
 * @param input Input image which is being converted. Not modified.
 * @param output (Optional) The output image.  If null a new image is created. Modified.
 * @return Converted image.
 */
public static GrayS8 convert(GrayF64 input, GrayS8 output) {
  if (output == null) {
    output = new GrayS8(input.width, input.height);
  } else {
    output.reshape(input.width,input.height);
  }
  ImplConvertImage.convert(input, output);
  return output;
}
origin: org.boofcv/boofcv-ip

@Override
public Number get(int x, int y) {
  return image.get(x,y);
}
origin: org.boofcv/boofcv-ip

/**
 * Computes the variance of pixel intensity values inside the image.
 *
 * @param img Input image. Not modified.
 * @param mean Mean pixel intensity value.   
 * @return Pixel variance   
 */
public static double variance( GrayS8 img , double mean ) {
  double variance = 0;
  for (int y = 0; y < img.height; y++) {
    int index = img.getStartIndex() + y * img.getStride();
    int indexEnd = index+img.width;
    // for(int x = 0; x < img.width; x++ ) {
    for (; index < indexEnd; index++ ) {
      double d = (img.data[index]) - mean; 
      variance += d*d;
    }
  }
  return variance/(img.width*img.height);
}
origin: org.boofcv/visualize

public static BufferedImage renderOrientation4(GrayS8 direction , GrayF32 intensity , float threshold , BufferedImage out ) {
    out = new BufferedImage(direction.getWidth(),direction.getHeight(),BufferedImage.TYPE_INT_RGB);
    int data[] = raster.getDataStorage();
    int w = direction.getWidth();
    int h = direction.getHeight();
origin: org.boofcv/boofcv-ip

public static void convert( GrayS8 from, GrayI8 to ) {
  if (from.isSubimage() || to.isSubimage()) {
    for (int y = 0; y < from.height; y++) {
      int indexFrom = from.getIndex(0, y);
      int indexTo = to.getIndex(0, y);
      for (int x = 0; x < from.width; x++) {
        to.data[indexTo++] = ( from.data[indexFrom++] );
      }
    }
  } else {
    final int N = from.width * from.height;
    System.arraycopy(from.data, 0, to.data, 0, N);
  }
}
origin: org.boofcv/boofcv-ip

  @Override
  public GrayS8 createNew(int imgWidth, int imgHeight) {
    if (imgWidth == -1 || imgHeight == -1) {
      return new GrayS8();
    }
    return new GrayS8(imgWidth, imgHeight);
  }
}
origin: org.boofcv/boofcv-ip

  to.setTo(from.getBand(0));
} else if( numBands == 3 ) {
  GrayS8 band0 = from.getBand(0);
    int indexTo = to.getIndex(0, y);
  for (int y = 0; y < from.height; y++) {
    int indexFrom = from.getIndex(0, y);
    int indexTo = to.getIndex(0, y);
origin: org.boofcv/boofcv-ip

@Override
public int unsafe_get(int x, int y) {
  return data[getIndex(x, y)];
}
origin: org.boofcv/feature

suppressed.reshape(input.width,input.height);
angle.reshape(input.width,input.height);
direction.reshape(input.width,input.height);
work.reshape(input.width,input.height);
origin: org.boofcv/boofcv-swing

public static BufferedImage renderOrientation4(GrayS8 direction , GrayF32 intensity , float threshold , BufferedImage out ) {
    out = new BufferedImage(direction.getWidth(),direction.getHeight(),BufferedImage.TYPE_INT_RGB);
    int offsetDst = ConvertRaster.getOffset(raster);
    int w = direction.getWidth();
    int h = direction.getHeight();
origin: org.boofcv/boofcv-ip

public static void convert( GrayS8 from, GrayF32 to ) {
  if (from.isSubimage() || to.isSubimage()) {
    for (int y = 0; y < from.height; y++) {
      int indexFrom = from.getIndex(0, y);
      int indexTo = to.getIndex(0, y);
      for (int x = 0; x < from.width; x++) {
        to.data[indexTo++] = ( float )( from.data[indexFrom++] );
      }
    }
  } else {
    final int N = from.width * from.height;
    for (int i = 0; i < N; i++) {
      to.data[i] = ( float )( from.data[i] );
    }
  }
}
origin: org.boofcv/boofcv-ip

  public static <T extends ImageGray<T>> T create(Class<T> type , int width , int height )
  {
    if( type == GrayU8.class) {
      return (T)new GrayU8(width,height);
    } else if( type == GrayS8.class) {
      return (T)new GrayS8(width,height);
    } else if( type == GrayU16.class) {
      return (T)new GrayU16(width,height);
    } else if( type == GrayS16.class) {
      return (T)new GrayS16(width,height);
    } else if( type == GrayS32.class) {
      return (T)new GrayS32(width,height);
    } else if( type == GrayF32.class) {
      return (T)new GrayF32(width,height);
    } else{
      throw new IllegalArgumentException("Unknown image type: "+type);
    }
  }
}
origin: org.boofcv/boofcv-ip

for (int y = 0; y < from.height; y++) {
  int indexFrom = from.getIndex(0, y);
  int indexTo = to.getIndex(0, y);
  System.arraycopy(from.data,indexFrom,to.data,indexTo,from.width);
for (int y = 0; y < from.height; y++) {
  int indexFrom = from.getIndex(0, y);
  int indexTo = to.getIndex(0, y);
  int indexEndTo = indexTo + from.width;
for (int y = 0; y < from.height; y++) {
  int indexFrom = from.getIndex(0, y);
  int indexTo = to.getIndex(0, y);
  int indexEndTo = indexTo + from.width;
for (int y = 0; y < from.height; y++) {
  int indexFrom = from.getIndex(0, y);
  int indexTo = to.getIndex(0, y);
origin: org.boofcv/boofcv-ip

/**
 * Adds uniform i.i.d noise to each pixel in the image.  Noise range is min &le; X &lt; max.
 */
public static void addUniform(GrayS8 input, Random rand , int min , int max) {
  int range = max-min;
  byte[] data = input.data;
  for (int y = 0; y < input.height; y++) {
    int index = input.getStartIndex() + y * input.getStride();
    for (int x = 0; x < input.width; x++) {
      int value = (data[index] ) + rand.nextInt(range)+min;
      if( value < -128 ) value = -128;
      if( value > 127 ) value = 127;
      data[index++] = (byte) value;
    }
  }
}
origin: org.boofcv/boofcv-ip

/**
 * <p>
 * Computes the absolute value of the difference between each pixel in the two images.<br>
 * d(x,y) = |img1(x,y) - img2(x,y)|
 * </p>
 * @param imgA Input image. Not modified.
 * @param imgB Input image. Not modified.
 * @param diff Absolute value of difference image. Modified.
 */
public static void diffAbs(GrayS8 imgA , GrayS8 imgB , GrayS8 diff ) {
  InputSanityCheck.checkSameShape(imgA,imgB,diff);
  
  final int h = imgA.getHeight();
  final int w = imgA.getWidth();
  for (int y = 0; y < h; y++) {
    int indexA = imgA.getStartIndex() + y * imgA.getStride();
    int indexB = imgB.getStartIndex() + y * imgB.getStride();
    int indexDiff = diff.getStartIndex() + y * diff.getStride();
    
    int indexEnd = indexA+w;
    // for(int x = 0; x < w; x++ ) {
    for (; indexA < indexEnd; indexA++, indexB++, indexDiff++ ) {
      diff.data[indexDiff] = (byte)Math.abs((imgA.data[indexA] ) - (imgB.data[indexB] ));
    }
  }
}
origin: org.boofcv/boofcv-ip

/**
 * <p>
 * Converts an {@link boofcv.struct.image.GrayS32} into a {@link boofcv.struct.image.GrayS8}.
 * </p>
 *
 * @param input Input image which is being converted. Not modified.
 * @param output (Optional) The output image.  If null a new image is created. Modified.
 * @return Converted image.
 */
public static GrayS8 convert(GrayS32 input, GrayS8 output) {
  if (output == null) {
    output = new GrayS8(input.width, input.height);
  } else {
    output.reshape(input.width,input.height);
  }
  ImplConvertImage.convert(input, output);
  return output;
}
origin: org.boofcv/boofcv-ip

public static void convert( GrayS8 from, GrayS32 to ) {
  if (from.isSubimage() || to.isSubimage()) {
    for (int y = 0; y < from.height; y++) {
      int indexFrom = from.getIndex(0, y);
      int indexTo = to.getIndex(0, y);
      for (int x = 0; x < from.width; x++) {
        to.data[indexTo++] = ( from.data[indexFrom++] );
      }
    }
  } else {
    final int N = from.width * from.height;
    for (int i = 0; i < N; i++) {
      to.data[i] = ( from.data[i] );
    }
  }
}
origin: org.boofcv/boofcv-ip

public static <T extends ImageGray<T>> T createSingleBand(Class<T> type, int width, int height) {
  type = BoofTesting.convertGenericToSpecificType(type);
  if (type == GrayU8.class) {
    return (T)new GrayU8(width, height);
  } else if (type == GrayS8.class) {
    return (T)new GrayS8(width, height);
  } else if (type == GrayS16.class) {
    return (T)new GrayS16(width, height);
  } else if (type == GrayU16.class) {
    return (T)new GrayU16(width, height);
  } else if (type == GrayS32.class) {
    return (T)new GrayS32(width, height);
  } else if (type == GrayS64.class) {
    return (T)new GrayS64(width, height);
  } else if (type == GrayF32.class) {
    return (T)new GrayF32(width, height);
  } else if (type == GrayF64.class) {
    return (T)new GrayF64(width, height);
  } else if( (Class)type == GrayI.class ) {
    // ImageInteger is a generic type, so just create something
    return (T)new GrayS32(width,height);
  }
  throw new RuntimeException("Unknown type: "+type.getSimpleName());
}
origin: org.boofcv/feature

int dir = direction.get(x,y);
int dx,dy;
boofcv.struct.imageGrayS8

Javadoc

Image with a pixel type of signed 8-bit integer.

Most used methods

  • getHeight
  • getWidth
  • <init>
    Creates a new gray scale (single band/color) image.
  • get
  • getIndex
  • reshape
  • getStartIndex
  • getStride
  • isSubimage
  • set
  • setTo
  • unsafe_get
  • setTo,
  • unsafe_get

Popular in Java

  • Reactive rest calls using spring rest template
  • runOnUiThread (Activity)
  • setContentView (Activity)
  • getSharedPreferences (Context)
  • BigDecimal (java.math)
    An immutable arbitrary-precision signed decimal.A value is represented by an arbitrary-precision "un
  • SocketException (java.net)
    This SocketException may be thrown during socket creation or setting options, and is the superclass
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • Stream (java.util.stream)
    A sequence of elements supporting sequential and parallel aggregate operations. The following exampl
  • JPanel (javax.swing)
  • Reflections (org.reflections)
    Reflections one-stop-shop objectReflections scans your classpath, indexes the metadata, allows you t
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now