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

How to use
GImageStatistics
in
boofcv.alg.misc

Best Java code snippets using boofcv.alg.misc.GImageStatistics (Showing top 20 results out of 315)

origin: org.boofcv/visualize

  public static ImagePanel showWindow(ImageGray img , String title , boolean showMagnitude) {
    double max = GImageStatistics.maxAbs(img);
    BufferedImage buff;
    if( showMagnitude )
      buff = VisualizeImageData.grayMagnitude(img,null,max);
    else
      buff = VisualizeImageData.colorizeSign(img,null,max);

    return showWindow(buff,title);
  }
}
origin: org.boofcv/feature

float max1 = (float)GImageStatistics.max(image1);
float max2 = (float)GImageStatistics.max(image2);
float min1 = (float)GImageStatistics.min(image1);
float min2 = (float)GImageStatistics.min(image2);
origin: org.boofcv/boofcv-ip

/**
 * <p>
 * Computes the variance based threshold using a modified Otsu method from an input image. Internally it uses
 * {@link #computeOtsu2(int[], int, int)} and {@link boofcv.alg.misc.GImageStatistics#histogram(ImageGray, double, int[])}
 * </p>
 *
 * @param input Input gray-scale image
 * @param minValue The minimum value of a pixel in the image.  (inclusive)
 * @param maxValue The maximum value of a pixel in the image.  (inclusive)
 * @return Selected threshold.
 */
public static int computeOtsu2(ImageGray input , int minValue , int maxValue ) {
  int range = 1+maxValue - minValue;
  int histogram[] = new int[ range ];
  GImageStatistics.histogram(input,minValue,histogram);
  // Total number of pixels
  int total = input.width*input.height;
  return computeOtsu2(histogram,range,total)+minValue;
}
origin: org.boofcv/boofcv-ip

private T ensureMaxValueOfOne(T input, double maxPixelValue) {
  T adjusted;
  if( maxPixelValue < 0 ) {
    maxPixelValue = GImageStatistics.max(input);
  }
  if( maxPixelValue != 1.0f ) {
    adjusted = this.adjusted;
    GPixelMath.divide(input, maxPixelValue, adjusted);
  } else {
    adjusted = input;
  }
  return adjusted;
}
origin: org.boofcv/demonstrations

public void process( BufferedImage input ) {
  setInputImage(input);
  this.input = input;
  workImage = ConvertBufferedImage.convertFromSingle(input, null, imageType);
  // update the binary histogram threshold for this image
  final double threshold = GImageStatistics.mean(workImage);
  binary.reshape(workImage.width,workImage.height);
  labeled.reshape(workImage.width,workImage.height);
  final int width = input.getWidth();
  final int height = input.getHeight();
  SwingUtilities.invokeLater(new Runnable() {
    public void run() {
      barBinary.setThreshold((int)threshold);
      barBinary.getHistogramPanel().update(workImage);
      panel.setPreferredSize(new Dimension(width,height));
      processedImage = true;
      doRefreshAll();
    }});
}
origin: org.boofcv/boofcv-ip

Planar in = (Planar) input;
for (int i = 0; i < in.getNumBands(); i++) {
  sum += sum( in.getBand(i));
origin: org.boofcv/boofcv-swing

  public static ImagePanel showWindow(ImageGray img , String title , boolean showMagnitude) {
    double max = GImageStatistics.maxAbs(img);
    BufferedImage buff;
    if( showMagnitude )
      buff = VisualizeImageData.grayMagnitude(img,null,max);
    else
      buff = VisualizeImageData.colorizeSign(img,null,max);

    return showWindow(buff,title);
  }
}
origin: org.boofcv/boofcv-ip

/**
 * <p>
 * Computes the variance based threshold using Otsu's method from an input image. Internally it uses
 * {@link #computeOtsu(int[], int, int)} and {@link boofcv.alg.misc.GImageStatistics#histogram(ImageGray, double, int[])}
 * </p>
 *
 * @param input Input gray-scale image
 * @param minValue The minimum value of a pixel in the image.  (inclusive)
 * @param maxValue The maximum value of a pixel in the image.  (inclusive)
 * @return Selected threshold.
 */
public static double computeOtsu(ImageGray input , double minValue , double maxValue ) {
  int range = (int)(1+maxValue - minValue);
  int histogram[] = new int[ range ];
  GImageStatistics.histogram(input,minValue,histogram);
  // Total number of pixels
  int total = input.width*input.height;
  return computeOtsu(histogram,range,total)+minValue;
}
origin: org.boofcv/visualize

/**
 * <p>
 * Renders a colored image where the color indicates the sign and intensity its magnitude.   The input is divided
 * by normalize to render it in the appropriate scale.
 * </p>
 *
 * @param src       Input single band image.
 * @param dst       Where the image is rendered into.  If null a new BufferedImage will be created and return.
 * @param normalize Used to normalize the input image. If &le; 0 then the max value will be used
 * @return Rendered image.
 */
public static BufferedImage colorizeSign(ImageGray src, BufferedImage dst, double normalize) {
  dst = checkInputs(src, dst);
  if (normalize <= 0) {
    normalize = GImageStatistics.maxAbs(src);
  }
  if (normalize == 0) {
    // sets the output to black
    ConvertBufferedImage.convertTo(src,dst,true);
    return dst;
  }
  if (src.getClass().isAssignableFrom(GrayF32.class)) {
    return colorizeSign((GrayF32) src, dst, (float) normalize);
  } else {
    return colorizeSign((GrayI) src, dst, (int) normalize);
  }
}
origin: org.boofcv/boofcv-ip

/**
 * <p>
 * Computes a threshold which maximizes the entropy between the foreground and background regions.  See
 * {@link #computeEntropy(int[], int, int)} for more details.
 * </p>
 *
 * @see boofcv.alg.misc.GImageStatistics#histogram(ImageGray, double, int[])
 *
 * @param input Input gray-scale image
 * @param minValue The minimum value of a pixel in the image.  (inclusive)
 * @param maxValue The maximum value of a pixel in the image.  (inclusive)
 * @return Selected threshold.
 */
public static double computeEntropy(ImageGray input , double minValue , double maxValue ) {
  int range = (int)(1 + maxValue - minValue);
  int histogram[] = new int[ range ];
  GImageStatistics.histogram(input,minValue,histogram);
  // Total number of pixels
  int total = input.width*input.height;
  return computeEntropy(histogram, range, total)+minValue;
}
origin: org.boofcv/boofcv-swing

/**
 * <p>
 * Renders a colored image where the color indicates the sign and intensity its magnitude.   The input is divided
 * by normalize to render it in the appropriate scale.
 * </p>
 *
 * @param src       Input single band image.
 * @param dst       Where the image is rendered into.  If null a new BufferedImage will be created and return.
 * @param normalize Used to normalize the input image. If &le; 0 then the max value will be used
 * @return Rendered image.
 */
public static BufferedImage colorizeSign(ImageGray src, BufferedImage dst, double normalize) {
  dst = checkInputs(src, dst);
  if (normalize <= 0) {
    normalize = GImageStatistics.maxAbs(src);
  }
  if (normalize == 0) {
    // sets the output to black
    ConvertBufferedImage.convertTo(src,dst,true);
    return dst;
  }
  if (src.getClass().isAssignableFrom(GrayF32.class)) {
    return colorizeSign((GrayF32) src, dst, (float) normalize);
  } else {
    return colorizeSign((GrayI) src, dst, (int) normalize);
  }
}
origin: org.boofcv/visualize

/**
 * <p>
 * Renders a gray scale image using color values from cold to hot.
 * </p>
 *
 * @param src       Input single band image.
 * @param dst       Where the image is rendered into.  If null a new BufferedImage will be created and return.
 * @param normalize Used to normalize the input image.
 * @return Rendered image.
 */
public static BufferedImage grayMagnitudeTemp(ImageGray src, BufferedImage dst, double normalize) {
  if (normalize < 0)
    normalize = GImageStatistics.maxAbs(src);
  dst = checkInputs(src, dst);
  if (src.getDataType().isInteger()) {
    return grayMagnitudeTemp((GrayI) src, dst, (int) normalize);
  } else {
    throw new RuntimeException("Add support");
  }
}
origin: org.boofcv/boofcv-swing

/**
 * <p>
 * Renders a gray scale image using color values from cold to hot.
 * </p>
 *
 * @param src       Input single band image.
 * @param dst       Where the image is rendered into.  If null a new BufferedImage will be created and return.
 * @param normalize Used to normalize the input image.
 * @return Rendered image.
 */
public static BufferedImage grayMagnitudeTemp(ImageGray src, BufferedImage dst, double normalize) {
  if (normalize < 0)
    normalize = GImageStatistics.maxAbs(src);
  dst = checkInputs(src, dst);
  if (src.getDataType().isInteger()) {
    return grayMagnitudeTemp((GrayI) src, dst, (int) normalize);
  } else {
    throw new RuntimeException("Add support");
  }
}
origin: org.boofcv/demonstrations

@Override
public void setActiveAlgorithm(int indexFamily, String name, final Object cookie) {
  if( image == null )
    return;
  D derivX = GeneralizedImageOps.createSingleBand(derivType, image.width, image.height);
  D derivY = GeneralizedImageOps.createSingleBand(derivType, image.width, image.height);
  panel.reset();
  Helper h = (Helper)cookie;
  D derivXX = GeneralizedImageOps.createSingleBand(derivType, image.width, image.height);
  D derivYY = GeneralizedImageOps.createSingleBand(derivType, image.width, image.height);
  D derivXY = GeneralizedImageOps.createSingleBand(derivType, image.width, image.height);
  h.gradient.process(image,derivX,derivY);
  h.hessian.process(derivX,derivY,derivXX,derivYY,derivXY);
  double max;
  max = GImageStatistics.maxAbs(derivX);
  panel.addImage(VisualizeImageData.colorizeSign(derivX,null,max),"X-derivative");
  max = GImageStatistics.maxAbs(derivY);
  panel.addImage(VisualizeImageData.colorizeSign(derivY,null,max),"Y-derivative");
  max = GImageStatistics.maxAbs(derivXX);
  panel.addImage(VisualizeImageData.colorizeSign(derivXX,null,max),"XX-derivative");
  max = GImageStatistics.maxAbs(derivYY);
  panel.addImage(VisualizeImageData.colorizeSign(derivYY,null,max),"YY-derivative");
  max = GImageStatistics.maxAbs(derivXY);
  panel.addImage(VisualizeImageData.colorizeSign(derivXY,null,max),"XY-derivative");
  processedImage = true;
  repaint();
}
origin: org.boofcv/visualize

/**
 * <p>
 * Renders a gray scale image of the input image's intensity.<br>
 * <br>
 * dst(i,j) = 255*abs(src(i,j))/normalize
 * </p>
 *
 * @param src       Input single band image.
 * @param dst       Where the image is rendered into.  If null a new BufferedImage will be created and return.
 * @param normalize Used to normalize the input image. If < 0 then this value is automatically computed.
 * @return Rendered image.
 */
public static BufferedImage grayMagnitude(ImageGray src, BufferedImage dst, double normalize) {
  if (normalize < 0)
    normalize = GImageStatistics.maxAbs(src);
  dst = checkInputs(src, dst);
  if (src.getDataType().isInteger()) {
    return grayMagnitude((GrayI) src, dst, (int) normalize);
  } else if( src instanceof GrayF32){
    return grayMagnitude((GrayF32) src, dst, (float) normalize);
  } else if( src instanceof GrayF64){
    return grayMagnitude((GrayF64) src, dst, (float) normalize);
  } else {
    throw new RuntimeException("Unsupported type");
  }
}
origin: org.boofcv/boofcv-swing

/**
 * <p>
 * Renders a gray scale image of the input image's intensity.<br>
 * <br>
 * dst(i,j) = 255*abs(src(i,j))/normalize
 * </p>
 *
 * @param src       Input single band image.
 * @param dst       Where the image is rendered into.  If null a new BufferedImage will be created and return.
 * @param normalize Used to normalize the input image. If < 0 then this value is automatically computed.
 * @return Rendered image.
 */
public static BufferedImage grayMagnitude(ImageGray src, BufferedImage dst, double normalize) {
  if (normalize < 0)
    normalize = GImageStatistics.maxAbs(src);
  dst = checkInputs(src, dst);
  if (src.getDataType().isInteger()) {
    return grayMagnitude((GrayI) src, dst, (int) normalize);
  } else if( src instanceof GrayF32){
    return grayMagnitude((GrayF32) src, dst, (float) normalize);
  } else if( src instanceof GrayF64){
    return grayMagnitude((GrayF64) src, dst, (float) normalize);
  } else {
    throw new RuntimeException("Unsupported type");
  }
}
origin: org.boofcv/boofcv-swing

  double max = GImageStatistics.maxAbs(srcInt);
  return colorizeSign(srcInt, dst, (int) max);
} else {
    dst = ConvertBufferedImage.convertTo((GrayU8) src, dst);
  } else {
    double max = GImageStatistics.maxAbs(srcInt);
    dst = grayUnsigned(srcInt, dst, (int) max);
origin: org.boofcv/visualize

  double max = GImageStatistics.maxAbs(srcInt);
  return colorizeSign(srcInt, dst, (int) max);
} else {
    dst = ConvertBufferedImage.convertTo((GrayU8) src, dst);
  } else {
    double max = GImageStatistics.maxAbs(srcInt);
    dst = grayUnsigned(srcInt, dst, (int) max);
origin: org.boofcv/demonstrations

@Override
public void setActiveAlgorithm(String name, Object cookie) {
  DerivType type = (DerivType)cookie;
  panel.reset();
  for( int radius = 1; radius <= 40; radius += 2 ) {
    int maxOrder = Math.max(type.orderX,type.orderY);
    double sigma = FactoryKernelGaussian.sigmaForRadius(radius,maxOrder);
    Class typeKer1 = FactoryKernel.getKernelType(imageType,1);
    Kernel1D kerX =  FactoryKernelGaussian.derivativeK(typeKer1,type.orderX,sigma,radius);
    Kernel1D kerY = FactoryKernelGaussian.derivativeK(typeKer1,type.orderY,sigma,radius);
    Kernel2D kernel = GKernelMath.convolve(kerY, kerX);
    T smallImg = GKernelMath.convertToImage(kernel);
    new FDistort(smallImg,largeImg).interpNN().scaleExt().apply();
    double maxValue = GImageStatistics.maxAbs(largeImg);
    BufferedImage out = VisualizeImageData.colorizeSign(largeImg,null,maxValue);
    panel.addImage(out,String.format("%5d",radius));
  }
}
origin: org.boofcv/demonstrations

@Override
public void setActiveAlgorithm(String name, Object cookie) {
  DisplayGaussianKernelApp.DerivType dt = (DisplayGaussianKernelApp.DerivType)cookie;
  // add basis
  SteerableKernel<K> steerable = createKernel(dt.orderX,dt.orderY);
  basisPanel.reset();
  for( int i = 0; i < steerable.getBasisSize(); i++ ) {
    T smallImg = GKernelMath.convertToImage(steerable.getBasis(i));
    new FDistort(smallImg,largeImg).scaleExt().interpNN().apply();
    double maxValue = GImageStatistics.maxAbs(largeImg);
    BufferedImage out = VisualizeImageData.colorizeSign(largeImg,null,maxValue);
    basisPanel.addImage(out,"Basis "+i);
  }
  // add steered kernels
  steerPanel.reset();
  for( int i = 0; i <= 20; i++  ) {
    double angle = Math.PI*i/20.0;
    K kernel = steerable.compute(angle);
    T smallImg = GKernelMath.convertToImage(kernel);
    new FDistort(smallImg,largeImg).scaleExt().interpNN().apply();
    double maxValue = GImageStatistics.maxAbs(largeImg);
    BufferedImage out = VisualizeImageData.colorizeSign(largeImg,null,maxValue);
    steerPanel.addImage(out,String.format("%5d",(int)(180.0*angle/Math.PI)));
  }
  repaint();
}
boofcv.alg.miscGImageStatistics

Javadoc

Generalized version of ImageStatistics. Type checking is performed at runtime instead of at compile type.

Most used methods

  • maxAbs
    Returns the absolute value of the element with the largest absolute value, across all bands
  • max
    Returns the maximum pixel value across all bands.
  • histogram
    Computes the histogram of intensity values for the image. For floating point images it is rounded to
  • mean
    Returns the mean pixel intensity value.
  • min
    Returns the minimum pixel value across all bands
  • sum
    Returns the sum of all the pixels in the image across all bands.

Popular in Java

  • Running tasks concurrently on multiple threads
  • onRequestPermissionsResult (Fragment)
  • addToBackStack (FragmentTransaction)
  • setScale (BigDecimal)
  • PrintStream (java.io)
    Fake signature of an existing Java class.
  • Thread (java.lang)
    A thread is a thread of execution in a program. The Java Virtual Machine allows an application to ha
  • SocketException (java.net)
    This SocketException may be thrown during socket creation or setting options, and is the superclass
  • TimerTask (java.util)
    The TimerTask class represents a task to run at a specified time. The task may be run once or repeat
  • Vector (java.util)
    Vector is an implementation of List, backed by an array and synchronized. All optional operations in
  • Reference (javax.naming)
  • Best IntelliJ 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