當前位置: 首頁>>代碼示例>>Java>>正文


Java LuminanceSource.getWidth方法代碼示例

本文整理匯總了Java中com.google.zxing.LuminanceSource.getWidth方法的典型用法代碼示例。如果您正苦於以下問題:Java LuminanceSource.getWidth方法的具體用法?Java LuminanceSource.getWidth怎麽用?Java LuminanceSource.getWidth使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.zxing.LuminanceSource的用法示例。


在下文中一共展示了LuminanceSource.getWidth方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: binarizeEntireImage

import com.google.zxing.LuminanceSource; //導入方法依賴的package包/類
private void binarizeEntireImage() throws NotFoundException {
  if (matrix == null) {
    LuminanceSource source = getLuminanceSource();
    if (source.getWidth() >= MINIMUM_DIMENSION && source.getHeight() >= MINIMUM_DIMENSION) {
      byte[] luminances = source.getMatrix();
      int width = source.getWidth();
      int height = source.getHeight();
      int subWidth = width >> 3;
      if ((width & 0x07) != 0) {
        subWidth++;
      }
      int subHeight = height >> 3;
      if ((height & 0x07) != 0) {
        subHeight++;
      }
      int[][] blackPoints = calculateBlackPoints(luminances, subWidth, subHeight, width, height);

      matrix = new BitMatrix(width, height);
      calculateThresholdForBlock(luminances, subWidth, subHeight, width, height, blackPoints, matrix);
    } else {
      // If the image is too small, fall back to the global histogram approach.
      matrix = super.getBlackMatrix();
    }
  }
}
 
開發者ID:emdete,項目名稱:Simplicissimus,代碼行數:26,代碼來源:HybridBinarizer.java

示例2: getBlackRow

import com.google.zxing.LuminanceSource; //導入方法依賴的package包/類
@Override
public BitArray getBlackRow(int y, BitArray row) throws NotFoundException {
  LuminanceSource source = getLuminanceSource();
  int width = source.getWidth();
  if (row == null || row.getSize() < width) {
    row = new BitArray(width);
  } else {
    row.clear();
  }

  initArrays(width);
  byte[] localLuminances = source.getRow(y, luminances);
  int[] localBuckets = buckets;
  for (int x = 0; x < width; x++) {
    int pixel = localLuminances[x] & 0xff;
    localBuckets[pixel >> LUMINANCE_SHIFT]++;
  }
  int blackPoint = estimateBlackPoint(localBuckets);

  int left = localLuminances[0] & 0xff;
  int center = localLuminances[1] & 0xff;
  for (int x = 1; x < width - 1; x++) {
    int right = localLuminances[x + 1] & 0xff;
    // A simple -1 4 -1 box filter with a weight of 2.
    int luminance = ((center * 4) - left - right) / 2;
    if (luminance < blackPoint) {
      row.set(x);
    }
    left = center;
    center = right;
  }
  return row;
}
 
開發者ID:amap-demo,項目名稱:weex-3d-map,代碼行數:34,代碼來源:GlobalHistogramBinarizer.java

示例3: getBlackMatrix

import com.google.zxing.LuminanceSource; //導入方法依賴的package包/類
/**
 * Calculates the final BitMatrix once for all requests. This could be called once from the
 * constructor instead, but there are some advantages to doing it lazily, such as making
 * profiling easier, and not doing heavy lifting when callers don't expect it.
 */
@Override
public BitMatrix getBlackMatrix() throws NotFoundException {
  if (matrix != null) {
    return matrix;
  }
  LuminanceSource source = getLuminanceSource();
  int width = source.getWidth();
  int height = source.getHeight();
  if (width >= MINIMUM_DIMENSION && height >= MINIMUM_DIMENSION) {
    byte[] luminances = source.getMatrix();
    int subWidth = width >> BLOCK_SIZE_POWER;
    if ((width & BLOCK_SIZE_MASK) != 0) {
      subWidth++;
    }
    int subHeight = height >> BLOCK_SIZE_POWER;
    if ((height & BLOCK_SIZE_MASK) != 0) {
      subHeight++;
    }
    int[][] blackPoints = calculateBlackPoints(luminances, subWidth, subHeight, width, height);

    BitMatrix newMatrix = new BitMatrix(width, height);
    calculateThresholdForBlock(luminances, subWidth, subHeight, width, height, blackPoints, newMatrix);
    matrix = newMatrix;
  } else {
    // If the image is too small, fall back to the global histogram approach.
    matrix = super.getBlackMatrix();
  }
  return matrix;
}
 
開發者ID:amap-demo,項目名稱:weex-3d-map,代碼行數:35,代碼來源:HybridBinarizer.java

示例4: getBlackRow

import com.google.zxing.LuminanceSource; //導入方法依賴的package包/類
@Override
public BitArray getBlackRow(int y, BitArray row) throws NotFoundException {
  LuminanceSource source = getLuminanceSource();
  int width = source.getWidth();
  if (row == null || row.getSize() < width) {
    row = new BitArray(width);
  } else {
    row.clear();
  }

  initArrays(width);
  byte[] localLuminances = source.getRow(y, luminances);
  int[] localBuckets = buckets;
  for (int x = 0; x < width; x++) {
    localBuckets[(localLuminances[x] & 0xff) >> LUMINANCE_SHIFT]++;
  }
  int blackPoint = estimateBlackPoint(localBuckets);

  if (width < 3) {
    // Special case for very small images
    for (int x = 0; x < width; x++) {
      if ((localLuminances[x] & 0xff) < blackPoint) {
        row.set(x);
      }
    }
  } else {
    int left = localLuminances[0] & 0xff;
    int center = localLuminances[1] & 0xff;
    for (int x = 1; x < width - 1; x++) {
      int right = localLuminances[x + 1] & 0xff;
      // A simple -1 4 -1 box filter with a weight of 2.
      if (((center * 4) - left - right) / 2 < blackPoint) {
        row.set(x);
      }
      left = center;
      center = right;
    }
  }
  return row;
}
 
開發者ID:10045125,項目名稱:QrCode,代碼行數:41,代碼來源:GlobalHistogramBinarizer.java

示例5: getBlackRow

import com.google.zxing.LuminanceSource; //導入方法依賴的package包/類
public BitArray getBlackRow(int y, BitArray row) throws NotFoundException {
    int x;
    LuminanceSource source = getLuminanceSource();
    int width = source.getWidth();
    if (row == null || row.getSize() < width) {
        row = new BitArray(width);
    } else {
        row.clear();
    }
    initArrays(width);
    byte[] localLuminances = source.getRow(y, this.luminances);
    int[] localBuckets = this.buckets;
    for (x = 0; x < width; x++) {
        int i = (localLuminances[x] & 255) >> 3;
        localBuckets[i] = localBuckets[i] + 1;
    }
    int blackPoint = estimateBlackPoint(localBuckets);
    int left = localLuminances[0] & 255;
    int center = localLuminances[1] & 255;
    for (x = 1; x < width - 1; x++) {
        int right = localLuminances[x + 1] & 255;
        if ((((center * 4) - left) - right) / 2 < blackPoint) {
            row.set(x);
        }
        left = center;
        center = right;
    }
    return row;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:30,代碼來源:GlobalHistogramBinarizer.java

示例6: getBlackMatrix

import com.google.zxing.LuminanceSource; //導入方法依賴的package包/類
public BitMatrix getBlackMatrix() throws NotFoundException {
    int y;
    byte[] localLuminances;
    LuminanceSource source = getLuminanceSource();
    int width = source.getWidth();
    int height = source.getHeight();
    BitMatrix matrix = new BitMatrix(width, height);
    initArrays(width);
    int[] localBuckets = this.buckets;
    for (y = 1; y < 5; y++) {
        int x;
        localLuminances = source.getRow((height * y) / 5, this.luminances);
        int right = (width * 4) / 5;
        for (x = width / 5; x < right; x++) {
            int i = (localLuminances[x] & 255) >> 3;
            localBuckets[i] = localBuckets[i] + 1;
        }
    }
    int blackPoint = estimateBlackPoint(localBuckets);
    localLuminances = source.getMatrix();
    for (y = 0; y < height; y++) {
        int offset = y * width;
        for (x = 0; x < width; x++) {
            if ((localLuminances[offset + x] & 255) < blackPoint) {
                matrix.set(x, y);
            }
        }
    }
    return matrix;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:31,代碼來源:GlobalHistogramBinarizer.java

示例7: getBlackMatrix

import com.google.zxing.LuminanceSource; //導入方法依賴的package包/類
public BitMatrix getBlackMatrix() throws NotFoundException {
    if (this.matrix != null) {
        return this.matrix;
    }
    LuminanceSource source = getLuminanceSource();
    int width = source.getWidth();
    int height = source.getHeight();
    if (width < 40 || height < 40) {
        this.matrix = super.getBlackMatrix();
    } else {
        byte[] luminances = source.getMatrix();
        int subWidth = width >> 3;
        if ((width & 7) != 0) {
            subWidth++;
        }
        int subHeight = height >> 3;
        if ((height & 7) != 0) {
            subHeight++;
        }
        int[][] blackPoints = calculateBlackPoints(luminances, subWidth, subHeight, width,
                height);
        BitMatrix newMatrix = new BitMatrix(width, height);
        calculateThresholdForBlock(luminances, subWidth, subHeight, width, height,
                blackPoints, newMatrix);
        this.matrix = newMatrix;
    }
    return this.matrix;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:29,代碼來源:HybridBinarizer.java

示例8: toBitmap

import com.google.zxing.LuminanceSource; //導入方法依賴的package包/類
private static Bitmap toBitmap(LuminanceSource source, int[] pixels) {
  int width = source.getWidth();
  int height = source.getHeight();
  Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
  bitmap.setPixels(pixels, 0, width, 0, 0, width, height);
  return bitmap;
}
 
開發者ID:mit-cml,項目名稱:appinventor-extensions,代碼行數:8,代碼來源:DecodeHandler.java

示例9: getBlackRow

import com.google.zxing.LuminanceSource; //導入方法依賴的package包/類
@Override
public BitArray getBlackRow(int y, BitArray row) throws NotFoundException {
  LuminanceSource source = getLuminanceSource();
  int width = source.getWidth();
  if (row == null || row.getSize() < width) {
    row = new BitArray(width);
  } else {
    row.clear();
  }

  initArrays(width);
  byte[] localLuminances = source.getRow(y, luminances);
  int[] localBuckets = buckets;
  for (int x = 0; x < width; x++) {
    int pixel = localLuminances[x] & 0xff;
    localBuckets[pixel >> LUMINANCE_SHIFT]++;
  }
  int blackPoint = estimateBlackPoint(localBuckets);

  int left = localLuminances[0] & 0xff;
  int center = localLuminances[1] & 0xff;
  for (int x = 1; x < width - 1; x++) {
    int right = localLuminances[x + 1] & 0xff;
    // A simple -1 4 -1 box filter with a weight of 2.
    int luminance = ((center << 2) - left - right) >> 1;
    if (luminance < blackPoint) {
      row.set(x);
    }
    left = center;
    center = right;
  }
  return row;
}
 
開發者ID:atomsheep,項目名稱:sres-app,代碼行數:34,代碼來源:GlobalHistogramBinarizer.java

示例10: getBlackRow

import com.google.zxing.LuminanceSource; //導入方法依賴的package包/類
@Override
public BitArray getBlackRow(int y, BitArray row) throws NotFoundException {
    LuminanceSource source = getLuminanceSource();
    int width = source.getWidth();
    if (row == null || row.getSize() < width) {
        row = new BitArray(width);
    } else {
        row.clear();
    }

    initArrays(width);
    byte[] localLuminances = source.getRow(y, luminances);
    int[] localBuckets = buckets;
    for (int x = 0; x < width; x++) {
        int pixel = localLuminances[x] & 0xff;
        localBuckets[pixel >> LUMINANCE_SHIFT]++;
    }
    int blackPoint = estimateBlackPoint(localBuckets);

    int left = localLuminances[0] & 0xff;
    int center = localLuminances[1] & 0xff;
    for (int x = 1; x < width - 1; x++) {
        int right = localLuminances[x + 1] & 0xff;
        // A simple -1 4 -1 box filter with a weight of 2.
        int luminance = ((center * 4) - left - right) / 2;
        if (luminance < blackPoint) {
            row.set(x);
        }
        left = center;
        center = right;
    }
    return row;
}
 
開發者ID:Ag47,項目名稱:TrueTone,代碼行數:34,代碼來源:GlobalHistogramBinarizer.java

示例11: getBlackMatrix

import com.google.zxing.LuminanceSource; //導入方法依賴的package包/類
/**
 * Calculates the final BitMatrix once for all requests. This could be called once from the
 * constructor instead, but there are some advantages to doing it lazily, such as making
 * profiling easier, and not doing heavy lifting when callers don't expect it.
 */
@Override
public BitMatrix getBlackMatrix() throws NotFoundException {
    if (matrix != null) {
        return matrix;
    }
    LuminanceSource source = getLuminanceSource();
    int width = source.getWidth();
    int height = source.getHeight();
    if (width >= MINIMUM_DIMENSION && height >= MINIMUM_DIMENSION) {
        byte[] luminances = source.getMatrix();
        int subWidth = width >> BLOCK_SIZE_POWER;
        if ((width & BLOCK_SIZE_MASK) != 0) {
            subWidth++;
        }
        int subHeight = height >> BLOCK_SIZE_POWER;
        if ((height & BLOCK_SIZE_MASK) != 0) {
            subHeight++;
        }
        int[][] blackPoints = calculateBlackPoints(luminances, subWidth, subHeight, width, height);

        BitMatrix newMatrix = new BitMatrix(width, height);
        calculateThresholdForBlock(luminances, subWidth, subHeight, width, height, blackPoints, newMatrix);
        matrix = newMatrix;
    } else {
        // If the image is too small, fall back to the global histogram approach.
        matrix = super.getBlackMatrix();
    }
    return matrix;
}
 
開發者ID:Ag47,項目名稱:TrueTone,代碼行數:35,代碼來源:HybridBinarizer.java

示例12: getBlackRow

import com.google.zxing.LuminanceSource; //導入方法依賴的package包/類
@Override
public BitArray getBlackRow(int y, BitArray row) throws NotFoundException {
    LuminanceSource source = getLuminanceSource();
    int width = source.getWidth();
    if (row == null || row.getSize() < width) {
        row = new BitArray(width);
    } else {
        row.clear();
    }

    initArrays(width);
    byte[] localLuminances = source.getRow(y, luminances);
    int[] localBuckets = buckets;
    for (int x = 0; x < width; x++) {
        int pixel = localLuminances[x] & 0xff;
        localBuckets[pixel >> LUMINANCE_SHIFT]++;
    }
    int blackPoint = estimateBlackPoint(localBuckets);

    int left = localLuminances[0] & 0xff;
    int center = localLuminances[1] & 0xff;
    for (int x = 1; x < width - 1; x++) {
        int right = localLuminances[x + 1] & 0xff;
        // A simple -1 4 -1 box filter with a weight of 2.
        int luminance = ((center << 2) - left - right) >> 1;
        if (luminance < blackPoint) {
            row.set(x);
        }
        left = center;
        center = right;
    }
    return row;
}
 
開發者ID:yakovenkodenis,項目名稱:Discounty,代碼行數:34,代碼來源:GlobalHistogramBinarizer.java

示例13: getBlackMatrix

import com.google.zxing.LuminanceSource; //導入方法依賴的package包/類
public BitMatrix getBlackMatrix()
{
    LuminanceSource luminancesource = getLuminanceSource();
    int i = luminancesource.getWidth();
    int j = luminancesource.getHeight();
    BitMatrix bitmatrix = new BitMatrix(i, j);
    a(i);
    int ai[] = e;
    for (int k = 1; k < 5; k++)
    {
        byte abyte1[] = luminancesource.getRow((j * k) / 5, d);
        int l1 = (i << 2) / 5;
        for (int i2 = i / 5; i2 < l1; i2++)
        {
            int j2 = (0xff & abyte1[i2]) >> 3;
            ai[j2] = 1 + ai[j2];
        }

    }

    int l = a(ai);
    byte abyte0[] = luminancesource.getMatrix();
    for (int i1 = 0; i1 < j; i1++)
    {
        int j1 = i1 * i;
        for (int k1 = 0; k1 < i; k1++)
        {
            if ((0xff & abyte0[j1 + k1]) < l)
            {
                bitmatrix.set(k1, i1);
            }
        }

    }

    return bitmatrix;
}
 
開發者ID:vishnudevk,項目名稱:MiBandDecompiled,代碼行數:38,代碼來源:GlobalHistogramBinarizer.java

示例14: getBlackRow

import com.google.zxing.LuminanceSource; //導入方法依賴的package包/類
public BitArray getBlackRow(int i, BitArray bitarray)
{
    int j = 1;
    LuminanceSource luminancesource = getLuminanceSource();
    int k = luminancesource.getWidth();
    byte abyte0[];
    int ai[];
    if (bitarray == null || bitarray.getSize() < k)
    {
        bitarray = new BitArray(k);
    } else
    {
        bitarray.clear();
    }
    a(k);
    abyte0 = luminancesource.getRow(i, d);
    ai = e;
    for (int l = 0; l < k; l++)
    {
        int j2 = (0xff & abyte0[l]) >> 3;
        ai[j2] = 1 + ai[j2];
    }

    int i1 = a(ai);
    int j1 = 0xff & abyte0[0];
    int k1 = 0xff & abyte0[j];
    int l1 = j1;
    while (j < k - 1) 
    {
        int i2 = 0xff & abyte0[j + 1];
        if ((k1 << 2) - l1 - i2 >> 1 < i1)
        {
            bitarray.set(j);
        }
        j++;
        l1 = k1;
        k1 = i2;
    }
    return bitarray;
}
 
開發者ID:vishnudevk,項目名稱:MiBandDecompiled,代碼行數:41,代碼來源:GlobalHistogramBinarizer.java

示例15: getBlackMatrix

import com.google.zxing.LuminanceSource; //導入方法依賴的package包/類
public BitMatrix getBlackMatrix()
{
    if (e != null)
    {
        return e;
    }
    LuminanceSource luminancesource = getLuminanceSource();
    if (luminancesource.getWidth() >= 40 && luminancesource.getHeight() >= 40)
    {
        byte abyte0[] = luminancesource.getMatrix();
        int i = luminancesource.getWidth();
        int j = luminancesource.getHeight();
        int k = i >> 3;
        if ((i & 7) != 0)
        {
            k++;
        }
        int l = j >> 3;
        if ((j & 7) != 0)
        {
            l++;
        }
        int ai[][] = a(abyte0, k, l, i, j);
        BitMatrix bitmatrix = new BitMatrix(i, j);
        a(abyte0, k, l, i, j, ai, bitmatrix);
        e = bitmatrix;
    } else
    {
        e = super.getBlackMatrix();
    }
    return e;
}
 
開發者ID:vishnudevk,項目名稱:MiBandDecompiled,代碼行數:33,代碼來源:HybridBinarizer.java


注:本文中的com.google.zxing.LuminanceSource.getWidth方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。