Saturday, 15 May 2010

java - image after binarization is coming as rotated -



java - image after binarization is coming as rotated -

here code converting png image binary image form.although sometime convert 1 image binary image form on other time convert binary image form image rotated angle..here buffered image input png image wana convert binary form

public static byte[][] binarizeimage(bufferedimage bfimage){ final int threshold = 160; int height = bfimage.getheight(); int width = bfimage.getwidth(); byte[][] image = new byte[width][height]; for(int i=0; i<width; i++){ for(int j=0; j<height; j++){ color c = new color(bfimage.getrgb(i,j)); int reddish = c.getred(); int greenish = c.getgreen(); int bluish = c.getblue(); if(red<threshold && green<threshold && blue<threshold){ image[i][j] = 1; }else{ image[i][j] = 0; } } } homecoming image; }

can pls tel problem.for images works other doesnt.i making utilize of getrgb function

edit: improving legibility.

java binary grayscale

No comments:

Post a Comment