matlab - Java rgb2 gray it's to dark -
i don't can convert exactely rgb image gray image..
my final image it's dark, , affects work.
i use code:
public static bufferedimage rgb2gray(bufferedimage bi)//converter { int heightlimit = bi.getheight(); int widthlimit = bi.gettilewidth(); bufferedimage converted = new bufferedimage(widthlimit, heightlimit, bufferedimage.type_byte_gray); (int height = 0; height < heightlimit; height++) { (int width = 0; width < widthlimit; width++) { color c = new color(bi.getrgb(width, height) & 0x00fffff); int newred = (int) ((0.2989f * c.getred()) * 1.45);//0.2989f int newgreen = (int) ((0.5870f * c.getgreen()) * 1.45);//0.5870f int newblue = (int) ((0.1140f * c.getblue()) * 1.45); int rooffset = newred + newgreen + newblue; converted.setrgb(width, height, rooffset); } } return converted; }
what wrong?
in matlab result it's perfect, code in java poor.
i not sure why works in matlab , not in java - except perhaps color representation not handled same way in both platforms (but that's speculating). however, there way want - doesn't answer specific question ("what's wrong?"), should doing hoping do:
Comments
Post a Comment