/** * Converts a {@link Planar} into a {@link ImageGray} by computing the average value of each pixel * across all the bands. * * @param input Input Planar image that is being converted. Not modified. * @param output (Optional) The single band output image. If null a new image is created. Modified. * @return Converted image. */ public static <T extends ImageGray<T>>T average(Planar<T> input , T output ) { Class type = input.getBandType(); if( type == GrayU8.class ) { return (T)ConvertImage.average((Planar<GrayU8>)input,(GrayU8)output); } else if( type == GrayS8.class ) { return (T)ConvertImage.average((Planar<GrayS8>)input,(GrayS8)output); } else if( type == GrayU16.class ) { return (T)ConvertImage.average((Planar<GrayU16>)input,(GrayU16)output); } else if( type == GrayS16.class ) { return (T)ConvertImage.average((Planar<GrayS16>)input,(GrayS16)output); } else if( type == GrayS32.class ) { return (T)ConvertImage.average((Planar<GrayS32>)input,(GrayS32)output); } else if( type == GrayS64.class ) { return (T)ConvertImage.average((Planar<GrayS64>)input,(GrayS64)output); } else if( type == GrayF32.class ) { return (T)ConvertImage.average((Planar<GrayF32>)input,(GrayF32)output); } else if( type == GrayF64.class ) { return (T)ConvertImage.average((Planar<GrayF64>)input,(GrayF64)output); } else { throw new IllegalArgumentException("Unknown image type: "+type.getSimpleName()); } }
return ConvertImage.convert((GrayU8)input,(int)min,(int)max,numValues,output); } else if( type == ImageDataType.S8) { return ConvertImage.convert((GrayS8)input,(int)min,(int)max,numValues,output); } else if( type == ImageDataType.U16 ) { return ConvertImage.convert((GrayU16)input,(int)min,(int)max,numValues,output); } else if( type == ImageDataType.S16 ) { return ConvertImage.convert((GrayS16)input,(int)min,(int)max,numValues,output); } else if( type == ImageDataType.S32 ) { return ConvertImage.convert((GrayS32)input,(int)min,(int)max,numValues,output); } else if( type == ImageDataType.S64 ) { return ConvertImage.convert((GrayS64)input,(long)min,(long)max,numValues,output); } else if( type == ImageDataType.F32 ) { return ConvertImage.convert((GrayF32)input,(float)min,(float)max,numValues,output); } else if( type == ImageDataType.F64 ) { return ConvertImage.convert((GrayF64)input,min,max,numValues,output); } else { throw new IllegalArgumentException("Unknown image type: " + type);
status = Status.PROCESSING; convertToBitmapDisplay(input); ConvertImage.convertU8F32(input,workImage);
/** * Converts a {@link Planar} into a {@link ImageGray} by computing the average value of each pixel * across all the bands. * * @param input Input Planar image that is being converted. Not modified. * @param output (Optional) The single band output image. If null a new image is created. Modified. * @return Converted image. */ public static <T extends ImageGray<T>>T average(ImageInterleaved input , T output ) { ImageDataType type = input.getImageType().getDataType(); if( type == ImageDataType.U8) { return (T)ConvertImage.average((InterleavedU8)input,(GrayU8)output); } else if( type == ImageDataType.S8) { return (T)ConvertImage.average((InterleavedS8)input,(GrayS8)output); } else if( type == ImageDataType.U16 ) { return (T)ConvertImage.average((InterleavedU16)input,(GrayU16)output); } else if( type == ImageDataType.S16 ) { return (T)ConvertImage.average((InterleavedS16)input,(GrayS16)output); } else if( type == ImageDataType.S32 ) { return (T)ConvertImage.average((InterleavedS32)input,(GrayS32)output); } else if( type == ImageDataType.S64 ) { return (T)ConvertImage.average((InterleavedS64)input,(GrayS64)output); } else if( type == ImageDataType.F32 ) { return (T)ConvertImage.average((InterleavedF32)input,(GrayF32)output); } else if( type == ImageDataType.F64 ) { return (T)ConvertImage.average((InterleavedF64)input,(GrayF64)output); } else { throw new IllegalArgumentException("Unknown image type: " + type); } }
public synchronized void update( final CirculantTracker tracker ) { if( hasSelected ) { RectangleLength2D_F32 r = tracker.getTargetLocation(); selected.x0 = (int)r.x0; selected.y0 = (int)r.y0; selected.x1 = selected.x0 + (int)r.width; selected.y1 = selected.y0 + (int)r.height; GrayF64 template = tracker.getTargetTemplate(); GrayF64 response = tracker.getResponse(); if( this.template == null ) { this.template = new BufferedImage(template.width,template.height,BufferedImage.TYPE_INT_RGB); this.response = new BufferedImage(template.width,template.height,BufferedImage.TYPE_INT_RGB); tmp.reshape(template.width,template.height); } ConvertImage.convert(template,tmp); PixelMath.plus(tmp, 0.5f, tmp); PixelMath.multiply(tmp,255,0,255,tmp); ConvertBufferedImage.convertTo(tmp,this.template,true); ConvertImage.convert(response,tmp); VisualizeImageData.colorizeSign(tmp,this.response,-1); } repaint(); }
public GrayF32 computeDisparity( Planar<GrayU8> rectColor1 , Planar<GrayU8> rectColor2 ) { GrayU8 rectifiedLeft = new GrayU8(rectColor1.width,rectColor1.height); GrayU8 rectifiedRight = new GrayU8(rectColor2.width,rectColor2.height); ConvertImage.average(rectColor1,rectifiedLeft); ConvertImage.average(rectColor2,rectifiedRight); // compute disparity StereoDisparity<GrayS16, GrayF32> disparityAlg = FactoryStereoDisparity.regionSubpixelWta(DisparityAlgorithms.RECT_FIVE, controls.minDisparity, controls.maxDisparity, 6, 6, 30, 3, 0.05, GrayS16.class); // Apply the Laplacian across the image to add extra resistance to changes in lighting or camera gain GrayS16 derivLeft = new GrayS16(rectColor1.width,rectColor1.height); GrayS16 derivRight = new GrayS16(rectColor2.width,rectColor2.height); LaplacianEdge.process(rectifiedLeft, derivLeft); LaplacianEdge.process(rectifiedRight,derivRight); // process and return the results disparityAlg.process(derivLeft, derivRight); return disparityAlg.getDisparity(); }
@Override public void process(GrayU8 input) { ConvertImage.convert(input, grayF); PixelMath.divide(grayF,255.0f,grayF); dft.forward(grayF, transform); DiscreteFourierTransformOps.shiftZeroFrequency(transform, true); DiscreteFourierTransformOps.magnitude(transform, grayF); PixelMath.log(grayF,grayF); float max = ImageStatistics.maxAbs(grayF); PixelMath.multiply(grayF, 255f / max, grayF); ConvertBitmap.grayToBitmap(grayF, bitmap, bitmapTmp); } }
@Override public void process(Planar<GrayU8> input) { ConvertImage.average(input,gray); ImageStatistics.histogram(gray,0, histogram); EnhanceImageOps.equalize(histogram, transform); for( int i = 0; i < 3; i++ ) EnhanceImageOps.applyTransform(input.getBand(i), transform, enhanced.getBand(i)); renderOutput(enhanced); } }
ConvertImage.convert(inputBinary,inputGray); PixelMath.multiply(inputGray,255,inputGray);
Planar<GrayU8> color = (Planar<GrayU8>)_input; ConvertImage.average(color,gray);
public boolean process(GrayF32 left, GrayF32 right, OverheadView<Planar<GrayF32>> overhead) { Planar<GrayF32> overheadRGB = overhead.getImage(); gray.reshape(overheadRGB.getWidth(),overheadRGB.getHeight()); ConvertImage.average(overheadRGB,gray); if( !motion2D.process(gray) ) { return false; } // take in account map units Se2_F64 a = motion2D.getFirstToCurrent(); motion.set(a); motion.T.x = a.T.x*overhead.cellSize; motion.T.y = a.T.y*overhead.cellSize; return true; }
ImageFloat32.class); ImageFloat32 greyscaleImage = ConvertImage.average((MultiSpectral<ImageFloat32>) colorImage, null);