コード例 #1
0
 public void estimateBlackPoint(BlackPointEstimationMethod method, int argument)
 {
     if (!method.Equals(lastMethod) || argument != lastArgument)
     {
         int   width     = getWidth();
         int   height    = getHeight();
         int[] histogram = new int[LUMINANCE_BUCKETS];
         if (method.Equals(BlackPointEstimationMethod.TWO_D_SAMPLING))
         {
             int minDimension = width < height ? width : height;
             int startX       = (width - minDimension) >> 1;
             int startY       = (height - minDimension) >> 1;
             for (int n = 0; n < minDimension; n++)
             {
                 int luminance = getLuminance(startX + n, startY + n);
                 histogram[luminance >> LUMINANCE_SHIFT]++;
             }
         }
         else if (method.Equals(BlackPointEstimationMethod.ROW_SAMPLING))
         {
             if (argument < 0 || argument >= height)
             {
                 throw new Exception("Row is not within the image: " + argument);
             }
             initLuminances();
             luminances = getLuminanceRow(argument, luminances);
             for (int x = 0; x < width; x++)
             {
                 histogram[luminances[x] >> LUMINANCE_SHIFT]++;
             }
         }
         else
         {
             throw new Exception("Unknown method: " + method);
         }
         blackPoint   = BlackPointEstimator.estimate(histogram) << LUMINANCE_SHIFT;
         lastMethod   = method;
         lastArgument = argument;
     }
 }
コード例 #2
0
 protected BaseMonochromeBitmapSource()
 {
     blackPoint   = 0x7F;
     lastMethod   = null;
     lastArgument = 0;
 }
コード例 #3
0
 protected BaseMonochromeBitmapSource() {
   blackPoint = 0x7F;
   lastMethod = null;
   lastArgument = 0;
 }
コード例 #4
0
 public void estimateBlackPoint(BlackPointEstimationMethod method, int argument){
   if (!method.Equals(lastMethod) || argument != lastArgument) {
     int width = getWidth();
     int height = getHeight();
     int[] histogram = new int[LUMINANCE_BUCKETS];
     if (method.Equals(BlackPointEstimationMethod.TWO_D_SAMPLING)) {
       int minDimension = width < height ? width : height;
       int startX = (width - minDimension) >> 1;
       int startY = (height - minDimension) >> 1;
       for (int n = 0; n < minDimension; n++) {
         int luminance = getLuminance(startX + n, startY + n);
         histogram[luminance >> LUMINANCE_SHIFT]++;
       }
     } else if (method.Equals(BlackPointEstimationMethod.ROW_SAMPLING)) {
       if (argument < 0 || argument >= height) {
         throw new Exception("Row is not within the image: " + argument);
       }
       initLuminances();
       luminances = getLuminanceRow(argument, luminances);
       for (int x = 0; x < width; x++) {
         histogram[luminances[x] >> LUMINANCE_SHIFT]++;
       }
     } else {
         throw new Exception("Unknown method: " + method);
     }
     blackPoint = BlackPointEstimator.estimate(histogram) << LUMINANCE_SHIFT;
     lastMethod = method;
     lastArgument = argument;
   }
 }