/** * Provides recent images from all the cameras (should be time and lighting synchronized) and renders them * into an equirectangular image. The images must be in the same order that the cameras were added. * * @param cameraImages List of camera images */ public void render( List<T> cameraImages ) { if( cameraImages.size() != cameras.size()) throw new IllegalArgumentException("Input camera image count doesn't equal the expected number"); // avoid divide by zero errors by initializing it to a small non-zero value GImageMiscOps.fill(weightImage,1e-4); GImageMiscOps.fill(averageImage,0); for (int i = 0; i < cameras.size(); i++) { Camera c = cameras.get(i); T cameraImage = cameraImages.get(i); distort.setModel(c.equiToCamera); distort.apply(cameraImage,cameraRendered); /// sum up the total weight for each pixel PixelMath.add(weightImage,c.mask,weightImage); // apply the weight for this image to the rendered image GPixelMath.multiply(c.mask,cameraRendered,workImage); // add the result to the average image GPixelMath.add(workImage, averageImage, averageImage); } // comput the final output by dividing GPixelMath.divide(averageImage,weightImage,averageImage); }
/** * Applies the specified corruption to the image. * @param original Original uncorrupted image. * @param corrupted Corrupted mage. */ public <T extends ImageGray<T>> void corruptImage(T original , T corrupted ) { GGrayImageOps.stretch(original, valueScale, valueOffset, 255.0, corrupted); GImageMiscOps.addGaussian(corrupted, rand, valueNoise, 0, 255); GPixelMath.boundImage(corrupted,0,255); }
/** * Sets each pixel in the output image to log( 1 + input(x,y)) of the input image. * Both the input and output image can be the same instance. * * @param input The input image. Not modified. * @param output Where the log image is written to. Modified. */ public static <T extends ImageBase<T>> void log(T input , T output ) { if( input instanceof ImageGray ) { if (GrayF32.class == input.getClass()) { PixelMath.log((GrayF32) input, (GrayF32) output); } else if (GrayF64.class == input.getClass()) { PixelMath.log((GrayF64) input, (GrayF64) output); } else { throw new IllegalArgumentException("Unknown image Type: " + input.getClass().getSimpleName()); } } else if( input instanceof Planar ) { Planar in = (Planar)input; Planar out = (Planar)output; for (int i = 0; i < in.getNumBands(); i++) { log( in.getBand(i), out.getBand(i)); } } }
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; }
public void process( BufferedImage image ) { input.reshape(image.getWidth(),image.getHeight()); noisy.reshape(input.width,input.height); output.reshape(input.width,input.height); deriv.reshape(input.width,input.height); ConvertBufferedImage.convertFromSingle(image, input, imageType); // add noise to the image noisy.setTo(input); GImageMiscOps.addGaussian(noisy, rand, noiseSigma, 0, 255); GPixelMath.boundImage(noisy,0,255); // compute edge image for weighted error GImageDerivativeOps.laplace(input,deriv); GPixelMath.abs(deriv,deriv); SwingUtilities.invokeLater(new Runnable() { public void run() { images.clear(); images.add(ConvertBufferedImage.convertTo(output,null,true)); images.add(ConvertBufferedImage.convertTo(noisy,null,true)); images.add(ConvertBufferedImage.convertTo(input,null,true)); info.reset(); doRefreshAll(); }}); }
multiply(in.getBand(i),value,out.getBand(i));
add(inA.getBand(i),inB.getBand(i),out.getBand(i));
abs(in.getBand(i),out.getBand(i));
diffAbs( inA.getBand(i), inB.getBand(i), out.getBand(i));
/** * Massage the input image into a format recognized by the network */ protected Planar<GrayF32> preprocess(Planar<GrayF32> image) { super.preprocess(image); // image net is BGR color order imageBgr.bands[0] = imageRgb.bands[2]; imageBgr.bands[1] = imageRgb.bands[1]; imageBgr.bands[2] = imageRgb.bands[0]; // image needs to be between 0 and 1 GPixelMath.divide(imageBgr,255,imageBgr); // Normalize the image's statistics for (int band = 0; band < 3; band++) { DataManipulationOps.normalize(imageBgr.getBand(band),mean[band],stdev[band]); } return imageBgr; } }
multiply(in.getBand(i),value,lower,upper,out.getBand(i));
/** * Provides recent images from all the cameras (should be time and lighting synchronized) and renders them * into an equirectangular image. The images must be in the same order that the cameras were added. * * @param cameraImages List of camera images */ public void render( List<T> cameraImages ) { if( cameraImages.size() != cameras.size()) throw new IllegalArgumentException("Input camera image count doesn't equal the expected number"); // avoid divide by zero errors by initializing it to a small non-zero value GImageMiscOps.fill(weightImage,1e-4); GImageMiscOps.fill(averageImage,0); for (int i = 0; i < cameras.size(); i++) { Camera c = cameras.get(i); T cameraImage = cameraImages.get(i); distort.setModel(c.equiToCamera); distort.apply(cameraImage,cameraRendered); /// sum up the total weight for each pixel PixelMath.add(weightImage,c.mask,weightImage); // apply the weight for this image to the rendered image GPixelMath.multiply(c.mask,cameraRendered,workImage); // add the result to the average image GPixelMath.add(workImage, averageImage, averageImage); } // comput the final output by dividing GPixelMath.divide(averageImage,weightImage,averageImage); }
divide(in.getBand(i),denominator,out.getBand(i));
multiply(inA.getBand(i), inB.getBand(i), out.getBand(i));
public void run() { noisy.setTo(input); GImageMiscOps.addGaussian(noisy,rand,noiseSigma,0,255); GPixelMath.boundImage(noisy,0,255); performDenoising(); }}); }
public void process( BufferedImage input ) { setInputImage(input); image.reshape(input.getWidth(),input.getHeight()); transform.reshape(input.getWidth(),input.getHeight()); magnitude.reshape(input.getWidth(),input.getHeight()); phase.reshape(input.getWidth(),input.getHeight()); ConvertBufferedImage.convertFrom(input, image, true); fft.forward(image,transform); GDiscreteFourierTransformOps.shiftZeroFrequency(transform,true); GDiscreteFourierTransformOps.magnitude(transform, magnitude); GDiscreteFourierTransformOps.phase(transform, phase); // Convert it to a log scale for visibility GPixelMath.log(magnitude, magnitude); SwingUtilities.invokeLater(new Runnable() { public void run() { setPreferredSize(new Dimension(image.width+50,image.height+20)); processedImage = true; }}); doRefreshAll(); }
divide(in.getBand(i),denominator,lower,upper,out.getBand(i));
boundImage( in.getBand(i), min, max);
divide(inA.getBand(i), inB.getBand(i), out.getBand(i));