亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

誰能告訴我這個函數的作用是什么?對圖像做了什么處理?最好能每一句都解釋?

誰能告訴我這個函數的作用是什么?對圖像做了什么處理?最好能每一句都解釋?

白豬掌柜的 2019-02-13 10:06:36
public Bitmap renderCroppedGreyscaleBitmap() {int width = getWidth();int height = getHeight();int[] pixels = new int[width * height];byte[] yuv = yuvData;int inputOffset = top * dataWidth + left;for (int y = 0; y < height; y++) {int outputOffset = y * width;for (int x = 0; x < width; x++) {int grey = yuv[inputOffset + x] & 0xff;pixels[outputOffset + x] = 0xFF000000 | (grey * 0x00010101);}inputOffset += dataWidth;}Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);bitmap.setPixels(pixels, 0, width, 0, 0, width, height);return bitmap;}}
查看完整描述

2 回答

?
jeck貓

TA貢獻1909條經驗 獲得超7個贊

首先是提取原始圖像的像素值byte[] yuv

然后逐個像素值進行灰度化int grey

最后二值化,將結果放在int[] pixels里邊

最后返回二值圖像return bitmap;



查看完整回答
反對 回復 2019-03-14
?
慕斯王

TA貢獻1864條經驗 獲得超2個贊

個人認為,這是一個 bitmap 圖像生成的函數
Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); 這個地方是 生成指定寬高和格式的bitmap

很多變量都是在類里定義的,還有自定義的類

查看完整回答
反對 回復 2019-03-14
  • 2 回答
  • 0 關注
  • 925 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號