110 likes | 225 Views
專題進度. 指導老師 : 鄭朝榮老師 組長 : 王俊元 組員 : 梁森凱 彭俊頎 朱勝群. 目標. 拍攝文字 將圖文傳入 將文字翻譯 回傳. 目前了解. 影像前處理 方向的旋轉 色彩的轉換 文字的細化 等 ……. 影像縮放. public class imageZoom { public static BufferedImage imageEnlarge(BufferedImage image,double n){
E N D
專題進度 指導老師:鄭朝榮老師 組長:王俊元 組員:梁森凱 彭俊頎 朱勝群
目標 • 拍攝文字 • 將圖文傳入 • 將文字翻譯 • 回傳
目前了解 • 影像前處理 • 方向的旋轉 • 色彩的轉換 • 文字的細化 • 等……
影像縮放 public class imageZoom { public static BufferedImage imageEnlarge(BufferedImage image,double n){ BufferedImage image1=new BufferedImage( (int)(image.getWidth()*n),(int)(image.getHeight()*n),image.getType()); for(int i = 0;i<image1.getWidth();i++){ for(int j=0;j<image1.getHeight();j++){ int x=(int)(i/n); int y=(int)(j/n); try{ image1.setRGB(i,j , image.getRGB(x, y)); }catch(Exception e){} } } return image1; } }
色彩的轉換 public class ImageClrChg { public static int gray[][]; public static void imagecolor(BufferedImage image){ gray =new int[image.getWidth()][image.getHeight()]; for(int h=0;h<image.getHeight();h++){ for(int w=0;w<image.getWidth();w++){ int rgb=image.getRGB(w, h); gray[w][h]=(r[w][h]+g[w][h]+b[w][h])/3; } } } public static BufferedImage ToGray(BufferedImage image) { imagecolor(image); for(int h=0;h<image.getHeight();h++){ for(int w=0;w<image.getWidth();w++){ int rgb=(0xff000000|gray[w][h]<<16|gray[w][h]<<8|gray[w][h]); image.setRGB(w, h, rgb); } } return image; } public static BufferedImage ToGreen(BufferedImage image) }
方向的旋轉 publicstatic BufferedImage imageRotationAngle(BufferedImage image,double theta){ int x0=image.getWidth()/2; int y0=image.getHeight()/2; double r0=Math.hypot(x0, y0)*2; BufferedImage image1=newBufferedImage((int)r0,(int)r0,BufferedImage.TYPE_INT_ARGB ); for(int i = 0;i<image1.getWidth();i++){ for(int j=0;j<image1.getHeight();j++){ int x1=i-x0; int y1=j-y0; double r=Math.hypot(x1, y1); double arfa=Math.atan2(y1, x1); x1=(int)(r0/2+r*Math.cos(arfa-theta)); y1=(int)(r0/2+r*Math.sin(arfa-theta)); //System.out.print(r+"=r\n"+arfa+"=θ\n"); try{ image1.setRGB(x1,y1 , image.getRGB(i, j)); }catch(Exception e){ } } } }
下次目標 • 影像的前處理完成
提供一個網頁 • http://www.free-ocr.com/