use of org.bytedeco.javacv.Java2DFrameConverter in project javacv by bytedeco.
the class RetinaExample method execute.
private void execute(String[] args) throws Exception {
BufferedImage bufferedImage = args.length >= 1 ? ImageIO.read(new File(args[0])) : ImageIO.read(this.getClass().getResourceAsStream("BlackBalls.jpg"));
System.out.println("Image type: " + bufferedImage.getType());
Mat matrix = new OpenCVFrameConverter.ToMat().convert(new Java2DFrameConverter().convert(bufferedImage));
normalize(matrix, matrix, 0, 255, NORM_MINMAX, -1, noArray());
showImage(matrix);
matrix.convertTo(matrix, CV_32F);
Mat gammaTransformedImage = new Mat(matrix.size(), CV_32F);
pow(matrix, 1. / 5, gammaTransformedImage);
Retina retina = createRetina(gammaTransformedImage.size());
Mat retinaOutput_parvo = new Mat();
Mat retinaOutput_magno = new Mat();
retina.clearBuffers();
retina.run(gammaTransformedImage);
retina.getParvo(retinaOutput_parvo);
retina.getMagno(retinaOutput_magno);
showImage(retinaOutput_parvo);
showImage(retinaOutput_magno);
}
use of org.bytedeco.javacv.Java2DFrameConverter in project javacv by bytedeco.
the class BioInspiredRetina method execute.
private void execute(String[] args) throws Exception {
BufferedImage bufferedImage = args.length >= 1 ? ImageIO.read(new File(args[0])) : ImageIO.read(this.getClass().getResourceAsStream("BlackBalls.jpg"));
System.out.println("Image type: " + bufferedImage.getType());
Mat matrix = new OpenCVFrameConverter.ToMat().convert(new Java2DFrameConverter().convert(bufferedImage));
normalize(matrix, matrix, 0, 255, NORM_MINMAX, -1, noArray());
showImage(matrix);
matrix.convertTo(matrix, CV_32F);
Mat gammaTransformedImage = new Mat(matrix.size(), CV_32F);
pow(matrix, 1. / 5, gammaTransformedImage);
Retina retina = Retina.create(gammaTransformedImage.size());
Mat retinaOutput_parvo = new Mat();
Mat retinaOutput_magno = new Mat();
retina.clearBuffers();
retina.run(gammaTransformedImage);
retina.getParvo(retinaOutput_parvo);
retina.getMagno(retinaOutput_magno);
showImage(retinaOutput_parvo);
showImage(retinaOutput_magno);
}
Aggregations