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; }
/** * 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); }
/** * 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; } }
/** * 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));
divide(in.getBand(i),denominator,lower,upper,out.getBand(i));
divide(inA.getBand(i), inB.getBand(i), out.getBand(i));