/** * Determines if given photo contains night picture. * * @param photo The photo to analyze. * @return True if the given photo contains night picture, false otherwise. */ public static boolean isNight(Photo photo) { BufferedImage img = ((SImage) photo.sImage).toBufferedImage(); Random rand = new Random(); int x, y; double souc = 0; for (int i = 0; i < settingsManager.getRandomPhotoSamplesNumber(); i++) { x = rand.nextInt(img.getWidth()); y = rand.nextInt(img.getHeight()); souc += argbToIntensity(img.getRGB(x, y)); } double val = (souc / settingsManager.getRandomPhotoSamplesNumber()); return val < settingsManager.getNightTreshold(); }