真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

java邊緣檢測代碼 邊緣檢測的目標(biāo)

java數(shù)字圖像處理常用算法

前些時(shí)候做畢業(yè)設(shè)計(jì) 用java做的數(shù)字圖像處理方面的東西 這方面的資料ms比較少 發(fā)點(diǎn)東西上來大家共享一下 主要就是些算法 有自己寫的 有人家的 還有改人家的 有的算法寫的不好 大家不要見笑

為永春等地區(qū)用戶提供了全套網(wǎng)頁設(shè)計(jì)制作服務(wù),及永春網(wǎng)站建設(shè)行業(yè)解決方案。主營業(yè)務(wù)為做網(wǎng)站、成都網(wǎng)站建設(shè)、永春網(wǎng)站設(shè)計(jì),以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專業(yè)、用心的態(tài)度為用戶提供真誠的服務(wù)。我們深信只要達(dá)到每一位用戶的要求,就會得到認(rèn)可,從而選擇與我們長期合作。這樣,我們也可以走得更遠(yuǎn)!

一 讀取bmp圖片數(shù)據(jù)

//? 獲取待檢測圖像? 數(shù)據(jù)保存在數(shù)組 nData[] nB[]? nG[]? nR[]中

public? void getBMPImage(String source) throws Exception {?????????? ???????? clearNData();??????????????????????? //清除數(shù)據(jù)保存區(qū)???????? FileInputStream fs = null;?????????????? try {??????????? fs = new FileInputStream(source);??????????? int bfLen = ;??????????? byte bf[] = new byte[bfLen];??????????? fs read(bf bfLen); // 讀取 字節(jié)BMP文件頭??????????? int biLen = ;??????????? byte bi[] = new byte[biLen];??????????? fs read(bi biLen); // 讀取 字節(jié)BMP信息頭

// 源圖寬度??????????? nWidth = (((int) bi[ ] xff) )??????????????????? | (((int) bi[ ] xff) )??????????????????? | (((int) bi[ ] xff) ) | (int) bi[ ] xff;

// 源圖高度??????????? nHeight = (((int) bi[ ] xff) )??????????????????? | (((int) bi[ ] xff) )??????????????????? | (((int) bi[ ] xff) ) | (int) bi[ ] xff;

// 位數(shù)??????????? nBitCount = (((int) bi[ ] xff) ) | (int) bi[ ] xff;

// 源圖大小??????????? int nSizeImage = (((int) bi[ ] xff) )??????????????????? | (((int) bi[ ] xff) )??????????????????? | (((int) bi[ ] xff) ) | (int) bi[ ] xff;

// 對 位BMP進(jìn)行解析??????????? if (nBitCount == ){??????????????? int nPad = (nSizeImage / nHeight) nWidth * ;??????????????? nData = new int[nHeight * nWidth];??????????????? nB=new int[nHeight * nWidth];??????????????? nR=new int[nHeight * nWidth];??????????????? nG=new int[nHeight * nWidth];??????????????? byte bRGB[] = new byte[(nWidth + nPad) * * nHeight];??????????????? fs read(bRGB (nWidth + nPad) * * nHeight);??????????????? int nIndex = ;??????????????? for (int j = ; j nHeight; j++){??????????????????? for (int i = ; i nWidth; i++) {??????????????????????? nData[nWidth * (nHeight j ) + i] = ( xff) ??????????????????????????????? | (((int) bRGB[nIndex + ] xff) )???????????????????????????????? | (((int) bRGB[nIndex + ] xff) )??????????????????????????????? | (int) bRGB[nIndex] xff;????????????????????? ??????????????????????? nB[nWidth * (nHeight j ) + i]=(int) bRGB[nIndex] xff;??????????????????????? nG[nWidth * (nHeight j ) + i]=(int) bRGB[nIndex+ ] xff;??????????????????????? nR[nWidth * (nHeight j ) + i]=(int) bRGB[nIndex+ ] xff;??????????????????????? nIndex += ;??????????????????? }??????????????????? nIndex += nPad;??????????????? }?//?????????????? Toolkit kit = Toolkit getDefaultToolkit();?//?????????????? image = kit createImage(new MemoryImageSource(nWidth nHeight ?//?????????????????????? nData nWidth));

/*?????????????? //調(diào)試數(shù)據(jù)的讀取

FileWriter fw = new FileWriter( C:\\Documents and Settings\\Administrator\\My Documents\\nDataRaw txt );//創(chuàng)建新文件??????????????? PrintWriter out = new PrintWriter(fw);??????????????? for(int j= ;jnHeight;j++){??????????????? ?for(int i= ;inWidth;i++){??????????????? ??out print(( * +nData[nWidth * (nHeight j ) + i])+ _ ??????????????? ????+nR[nWidth * (nHeight j ) + i]+ _ ??????????????? ????+nG[nWidth * (nHeight j ) + i]+ _ ??????????????? ????+nB[nWidth * (nHeight j ) + i]+ );??????????????? ????????????????? ?}??????????????? ?out println( );??????????????? }??????????????? out close();*/????????? ??????????? }??????? }??????? catch (Exception e) {??????????? e printStackTrace();??????????? throw new Exception(e);??????? } ??????? finally {??????????? if (fs != null) {??????????????? fs close();??????????? }??????? }???? //?? return image;??? }

二?由r g b 獲取灰度數(shù)組

public? int[] getBrightnessData(int rData[] int gData[] int bData[]){??? ???? ?int brightnessData[]=new int[rData length];??? ?if(rData length!=gData length || rData length!=bData length??? ???|| bData length!=gData length){??? ??return brightnessData;??? ?}??? ?else {??? ??for(int i= ;ibData length;i++){??? ???double temp= *rData[i]+ *gData[i]+ *bData[i];??? ???brightnessData[i]=(int)(temp)+((temp (int)(temp)) ? : );??? ??}??? ??return brightnessData;??? ?}??? ? ??? }?

三 直方圖均衡化

public int [] equilibrateGray(int[] PixelsGray int width int height) ??? {??????? ????????? int gray;???????? int length=PixelsGray length;???????? int FrequenceGray[]=new int[length]; ???????? int SumGray[]=new int[ ]; ???????? int ImageDestination[]=new int[length];???????? for(int i = ; i length ;i++) ??????? { ??????? ?? gray=PixelsGray[i]; ????????????? FrequenceGray[gray]++; ??????? } ????????? //??? 灰度均衡化 ???????? SumGray[ ]=FrequenceGray[ ]; ???????? for(int i= ;i ;i++){?????????????? SumGray[i]=SumGray[i ]+FrequenceGray[i];? ???????? }???????? for(int i= ;i ;i++) {?????????????? SumGray[i]=(int)(SumGray[i]* /length);? ???????? }???????? for(int i= ;iheight;i++) ???????? { ?????????????? for(int j= ;jwidth;j++) ????????????? { ????????????????? int k=i*width+j; ????????????????? ImageDestination[k]= xFF | ((SumGray[PixelsGray[k]] ??????????????????????????? ) | (SumGray[PixelsGray[k]] ) | SumGray[PixelsGray[k]]); ?????????????? } ????????? }???????? return ImageDestination;????? }?

四 laplace 階濾波 增強(qiáng)邊緣 圖像銳化

public int[] laplace DFileter(int []data int width int height){??? ??? ?int filterData[]=new int[data length];??? ?int min= ;??? ?int max= ;??? ?for(int i= ;iheight;i++){??? ??for(int j= ;jwidth;j++){??? ???if(i== || i==height || j== || j==width )??? ?????????? filterData[i*width+j]=data[i*width+j];??? ???else??? ????filterData[i*width+j]= *data[i*width+j] data[i*width+j ] data[i*width+j+ ]??? ???????????????????????? data[(i )*width+j] data[(i )*width+j ] data[(i )*width+j+ ]??? ???????????????????????? data[(i+ )*width+j] data[(i+ )*width+j ] data[(i+ )*width+j+ ];??? ?????? ???if(filterData[i*width+j]min)??? ????min=filterData[i*width+j];??? ???if(filterData[i*width+j]max)??? ????max=filterData[i*width+j];??? ??}????? ?}//??? ?System out println( max: +max);//??? ?System out println( min: +min);??? ???? ?for(int i= ;iwidth*height;i++){??? ??filterData[i]=(filterData[i] min)* /(max min);??? ?}??? ?return filterData;??? }?

五 laplace 階增強(qiáng)濾波 增強(qiáng)邊緣 增強(qiáng)系數(shù)delt

public int[] laplaceHigh DFileter(int []data int width int height double delt){??? ???? ?int filterData[]=new int[data length];??? ?int min= ;??? ?int max= ;??? ?for(int i= ;iheight;i++){??? ??for(int j= ;jwidth;j++){??? ???if(i== || i==height || j== || j==width )??? ?????????? filterData[i*width+j]=(int)(( +delt)*data[i*width+j]);??? ???else??? ????filterData[i*width+j]=(int)(( +delt)*data[i*width+j] data[i*width+j ]) data[i*width+j+ ]??? ???????????????????????? data[(i )*width+j] data[(i )*width+j ] data[(i )*width+j+ ]??? ???????????????????????? data[(i+ )*width+j] data[(i+ )*width+j ] data[(i+ )*width+j+ ];??? ?????? ???if(filterData[i*width+j]min)??? ????min=filterData[i*width+j];??? ???if(filterData[i*width+j]max)??? ????max=filterData[i*width+j];??? ??}????? ?}??? ?for(int i= ;iwidth*height;i++){??? ??filterData[i]=(filterData[i] min)* /(max min);??? ?}??? ?return filterData;??? }? 六 局部閾值處理 值化

//?? 局部閾值處理 值化 niblack s?? method??? /*原理 ?? ???????? T(x y)=m(x y)?? +?? k*s(x y)?? ???????? 取一個(gè)寬度為w的矩形框 (x y)為這個(gè)框的中心 ???????? 統(tǒng)計(jì)框內(nèi)數(shù)據(jù) T(x y)為閾值 m(x y)為均值 s(x y)為均方差 k為參數(shù)(推薦 )計(jì)算出t再對(x y)進(jìn)行切割 / ?? ???????? 這個(gè)算法的優(yōu)點(diǎn)是???? 速度快 效果好 ?? ???????? 缺點(diǎn)是???? niblack s?? method會產(chǎn)生一定的噪聲 ? ???? */??? ??? public int[] localThresholdProcess(int []data int width int height int w int h double coefficients double gate){??? ?int[] processData=new int[data length];??? ?for(int i= ;idata length;i++){??? ??processData[i]= ;??? ?}??? ???? ?if(data length!=width*height)??? ??return processData;??? ???? ?int wNum=width/w;??? ?int hNum=height/h;??? ?int delt[]=new int[w*h];??? ???? ?//System out println( w; +w+ ? h: +h+ ? wNum: +wNum+ hNum: +hNum);??? ???? ?for(int j= ;jhNum;j++){??? ??for(int i= ;iwNum;i++){??? ?//for(int j= ;j ;j++){??? ?//?for(int i= ;i ;i++){???? ??? for(int n= ;nh;n++)??? ?????????? for(int k= ;kw;k++){??? ????? ????? delt[n*w+k]=data[(j*h+n)*width+i*w+k];??? ????? ????? //System out print( delt[ +(n*w+k)+ ]: +delt[n*w+k]+ );??? ?????????? }??? ??? //System out println();??? ??? /*??? ??? for(int n= ;nh;n++)??? ?????????? for(int k= ;kw;k++){??? ????? ????? System out print( data[ +((j*h+n)*width+i*w+k)+ ]: +data[(j*h+n)*width+i*w+k]+ );??? ?????????? }??? ??? System out println();??? ??? */??? ??? delt=thresholdProcess(delt w h coefficients gate);??? ??? for(int n= ;nh;n++)??? ?????????? for(int k= ;kw;k++){??? ????? ????? processData[(j*h+n)*width+i*w+k]=delt[n*w+k];??? ????? ???? // System out print( delt[ +(n*w+k)+ ]: +delt[n*w+k]+ );??? ?????????? }??? ??? //System out println();??? ??? /*??? ??? for(int n= ;nh;n++)??? ?????????? for(int k= ;kw;k++){??? ????? ????? System out print( processData[ +((j*h+n)*width+i*w+k)+ ]: +processData[(j*h+n)*width+i*w+k]+ );??? ?????????? }??? ??? System out println();??? ??? */??? ??} ??? ?}??? ???? ?return processData;??? }?

七 全局閾值處理 值化

public int[] thresholdProcess(int []data int width int height double coefficients double gate){??? ?int [] processData=new int[data length];??? ?if(data length!=width*height)??? ??return processData;??? ?else{??? ??double sum= ;??? ??double average= ;??? ??double variance= ;??? ??double threshold;??? ????? ??if( gate!= ){??? ???threshold=gate;???? ??}??? ??else{??? ??????? for(int i= ;iwidth*height;i++){??? ???? ?? sum+=data[i];??? ??????? }??? ??????? average=sum/(width*height);??? ????? ??????? for(int i= ;iwidth*height;i++){??? ???? ???? variance+=(data[i] average)*(data[i] average);??? ??????? }??? ??????? variance=Math sqrt(variance);??? ??????? threshold=average coefficients*variance;??? ??}??? ????? ???? for(int i= ;iwidth*height;i++){??? ???? ?if(data[i]threshold)??? ???? ??? processData[i]= ;??? ???? ?else ??? ???? ?????? processData[i]= ;??? ???? }??? ????? ???? return processData;?????? }??? }?

八 ?垂直邊緣檢測 sobel算子

public int[] verticleEdgeCheck(int []data int width int height int sobelCoefficients) throws Exception{??? ?int filterData[]=new int[data length];??? ?int min= ;??? ?int max= ;??? ?if(data length!=width*height)??? ??return filterData;??? ???? ?try{??? ???? ?? for(int i= ;iheight;i++){??? ?? for(int j= ;jwidth;j++){??? ??? if(i== || i== || i==height || i==height ??? ?????? ||j== || j== || j==width || j==width ){??? ?????????? filterData[i*width+j]=data[i*width+j];??? ???? }??? ???? else{??? ????? double average;??? ??????? //中心的九個(gè)像素點(diǎn)??? ???????? //average=data[i*width+j] Math sqrt( )*data[i*width+j ]+Math sqrt( )*data[i*width+j+ ]??? ????? average=data[i*width+j] sobelCoefficients*data[i*width+j ]+sobelCoefficients*data[i*width+j+ ]?????? ??? ????????????? data[(i )*width+j ]+data[(i )*width+j+ ]??? ???????????????? data[(i+ )*width+j ]+data[(i+ )*width+j+ ];??? ???????? filterData[i*width+j]=(int)(average);??? ???? }?? ??? ??? ??? if(filterData[i*width+j]min)???? ????min=filterData[i*width+j];???? ??? if(filterData[i*width+j]max)???? ????max=filterData[i*width+j];??? ??? }??? ??? }??? ?? for(int i= ;iwidth*height;i++){????? ??filterData[i]=(filterData[i] min)* /(max min);????? ?? }??? ???? ?}??? ?catch (Exception e) ??? ?{??????????? e printStackTrace();??????????? throw new Exception(e);??????? }? ??? ???? ?return filterData;??? }?

九 ?圖像平滑 * 掩模處理(平均處理) 降低噪聲

lishixinzhi/Article/program/Java/hx/201311/26286

如何對BMP格式圖像進(jìn)行邊緣檢測或輪廓提取?

文件名稱: 圖象的邊沿檢測與提取,輪廓跟蹤算法代碼下載 收藏√ [ 5 4 3 2 1 ] 所屬分類: GDI-Bitmap 開發(fā)工具: C-C++ 文件大小: 31 KB 上傳時(shí)間: 2005-04-07 下載次數(shù): 66 提 供 者: 羅丁 詳細(xì)說明:圖像處理程序代碼,圖像邊緣檢測與提取,輪廓跟蹤算法-image processing code, edge detection and extraction, contour tracking algorithm

[上載源碼成為會員下載此源碼] [成為VIP會員下載此源碼...] 近期下載過的用戶: 柯萌 ZITAN lgmlgm 許述文 [查看上載者羅丁的更多信息] 相關(guān)搜索: 輪廓跟蹤 圖像處理 輪廓跟蹤算法 邊緣檢測 圖像邊緣檢測與提取 圖像輪廓提取原代碼 圖像 跟蹤 圖像邊緣檢測

Scanner在java中有什么用法怎么用

1、首先在一個(gè)java工程下創(chuàng)建一個(gè)類名的ScannerDemo的類。

2、然后創(chuàng)建一個(gè)Scanner類對象,讓它接收從鍵盤輸入的數(shù)據(jù)。

3、這里利用的nextLine方法接收字符串。next方法其實(shí)也是可以獲取字符串的。但是next不能獲取空格,比如輸入Hello World,使用next方法只會得到Hello;而使用nextLine方法會得到完整的Hello World;因?yàn)閚extLine方法是以回車鍵為結(jié)束標(biāo)識的。

4、在程序窗口空白處,點(diǎn)擊右鍵,選擇Run As ——Java Application。

5、這時(shí)在控制臺中,輸入字符串,按回車??梢钥吹嚼肧canner類的nextLine成功接收到字符串。

6、當(dāng)然Scanner除能接收字符串之外,像整數(shù),浮點(diǎn)數(shù)也是可以接收的,都有對應(yīng)的方法。下面就以接收整數(shù)為例,其他類型的也差不多,可以自己嘗試一下。

7、運(yùn)行查看結(jié)果,可以看到nextInt()只能接收整數(shù)。想要接收其他類型的數(shù)據(jù)就得用其他方法了。

擴(kuò)展資料:

Scanner類常用方法

1、String next():接收控制臺輸入的字符串(備注:不能將空格作為字符串接收);

2、String nextLine():接收控制臺輸入的字符串;

3、int nextInt():接收控制臺輸入的int類型的數(shù)據(jù);

4、double nextDouble:接收控制臺輸入的double 類型的數(shù)據(jù);

5、boolean nextBoolean():接收控制臺輸入的boolean 類型的數(shù)據(jù);

6、輸入char類型的數(shù)據(jù);

Scanner類沒有直接輸入char類型的方法,可以通過charAt()方法從next()或nexyLine()獲取。

參考資料:百度百科-計(jì)算機(jī)編程語言

一段java的canny邊緣檢測代碼,求詳細(xì)注解,越詳細(xì)越好

汗個(gè),這段代碼倒是有點(diǎn)像android的

就是將圖片大小排放計(jì)算出來顯示;

要注釋啊,傳源文件上來才好搞哦。里面有不少自定義的類和方法

如:image2pixels();


當(dāng)前文章:java邊緣檢測代碼 邊緣檢測的目標(biāo)
瀏覽路徑:http://weahome.cn/article/dojsoge.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部