import java.awt.Color;import java.io.*;import java.util.*;import java.text.*;import java.math.*;import java.util.regex.*;public class Solution {public static void main(String[] args) throws IOException {double sr = 0, sg = 0, sb = 0;double R, G, B;BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));int count =0;while(1==1){String str = reader.readLine();if(str==null) break;try{String temp[] = str.split(" ");for (int i = 0; i < temp.length; i++) {String pixcel[] = temp[i].split(",");sr+=Integer.parseInt(pixcel[0]);sg+=Integer.parseInt(pixcel[1]);sb+=Integer.parseInt(pixcel[2]);count++;}}catch(Exception ex){break;}}sr = (sr/count)/255.0;sg = (sg/count)/255.0;sb = (sg/count)/255.0;if(sr <= 0.03928){R = sr/12.92;}else{R = Math.pow((sr+0.055)/1.055, 2.4);}if(sg <= 0.03928){G = sg/12.92;}else{G = Math.pow((sg+0.055)/1.055, 2.4);}if(sb <= 0.03928){B = sb/12.92;}else{B = Math.pow((sb+0.055)/1.055, 2.4);}double y = 0.2126*R+0.7152*G+0.0722*B;if(y<0.07){System.out.println("night");}else{System.out.println("day");}}}
Thứ Ba, 25 tháng 8, 2015
How to detect image is day or night in Java
Just source code : image data is stdin
Đăng ký:
Bài đăng (Atom)