if( inputA instanceof ImageGray) { if (GrayU8.class == inputA.getClass()) { PixelMath.add((GrayU8) inputA, (GrayU8) inputB, (GrayU16) output); } else if (GrayS8.class == inputA.getClass()) { PixelMath.add((GrayS8) inputA, (GrayS8) inputB, (GrayS16) output); } else if (GrayU16.class == inputA.getClass()) { PixelMath.add((GrayU16) inputA, (GrayU16) inputB, (GrayS32) output); } else if (GrayS16.class == inputA.getClass()) { PixelMath.add((GrayS16) inputA, (GrayS16) inputB, (GrayS32) output); } else if (GrayS32.class == inputA.getClass()) { PixelMath.add((GrayS32) inputA, (GrayS32) inputB, (GrayS32) output); } else if (GrayS64.class == inputA.getClass()) { PixelMath.add((GrayS64) inputA, (GrayS64) inputB, (GrayS64) output); } else if (GrayF32.class == inputA.getClass()) { PixelMath.add((GrayF32) inputA, (GrayF32) inputB, (GrayF32) output); } else if (GrayF64.class == inputA.getClass()) { PixelMath.add((GrayF64) inputA, (GrayF64) inputB, (GrayF64) output); } else { throw new IllegalArgumentException("Unknown image Type: " + inputA.getClass().getSimpleName());
/** * 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); }
/** * 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); }