This effect deals with OneBandSource and Binary MatrixSource
@param source
@return image
964795
@Override
    public ImageSource apply(ImageSource source) {
        int width = source.getWidth();
        int height = source.getHeight();

        int[][] result = new int[height][width];

        if (source.isGrayscale()) {
            for (int i = 0; i < height; i++) {

                int iMin = Math.max(0, i - blockRadius);
                int iMax = Math.min(height, i + blockRadius + 1);
                int h = iMax - iMin;

                int jMin = Math.max(0, -blockRadius);
                int jMax = Math.min(width - 1, blockRadius);

                int[] hist = new int[bins + 1];
                int[] clippedHist = new int[bins + 1];

                for (int k = iMin; k < iMax; k++) {
                    for (int l = jMin; l < jMax; l++) {
                        ++hist[roundPositive(source.getGray(l, k) / 255.0f * bins)];
                    }
                }

                for (int j = 0; j < width; j++) {
                    int v = roundPositive(source.getGray(j, i) / 255.0f * bins);

                    int xMin = Math.max(0, j - blockRadius);
                    int xMax = j + blockRadius + 1;
                    int w = Math.min(width, xMax) - xMin;
                    int n = h * w;

                    int limit = (int) (slope * n / bins + 0.5f);

                    /* remove left behind values from histogram */
                    if (xMin > 0) {
                        int xMin1 = xMin - 1;
                        for (int yi = iMin; yi < iMax; ++yi) {
                            --hist[roundPositive(source.getGray(xMin1, yi) / 255.0f * bins)];
                        }
                    }

                    /* add newly included values to histogram */
                    if (xMax <= width) {
                        int xMax1 = xMax - 1;
                        for (int yi = iMin; yi < iMax; ++yi) {
                            ++hist[roundPositive(source.getGray(xMax1, yi) / 255.0f * bins)];
                        }
                    }

                    System.arraycopy(hist, 0, clippedHist, 0, hist.length);
                    int clippedEntries = 0, clippedEntriesBefore;

                    do {
                        clippedEntriesBefore = clippedEntries;
                        clippedEntries = 0;
                        for (int z = 0; z <= bins; ++z) {
                            int d = clippedHist[z] - limit;
                            if (d > 0) {
                                clippedEntries += d;
                                clippedHist[z] = limit;
                            }
                        }

                        int d = clippedEntries / (bins + 1);
                        int m = clippedEntries % (bins + 1);
                        for (int z = 0; z <= bins; ++z) {
                            clippedHist[z] += d;
                        }

                        if (m != 0) {
                            int s = bins / m;
                            for (int z = 0; z <= bins; z += s) {
                                ++clippedHist[z];
                            }
                        }
                    }
                    while (clippedEntries != clippedEntriesBefore);

                    /* build cdf of clipped histogram */
                    int hMin = bins;
                    for (int z = 0; z < hMin; ++z) {
                        if (clippedHist[z] != 0) hMin = z;
                    }

                    int cdf = 0;
                    for (int z = hMin; z <= v; ++z) {
                        cdf += clippedHist[z];
                    }

                    int cdfMax = cdf;
                    for (int z = v + 1; z <= bins; ++z) {
                        cdfMax += clippedHist[z];
                    }

                    int cdfMin = clippedHist[hMin];

                    result[i][j] = roundPositive((cdf - cdfMin) / (float) (cdfMax - cdfMin) * 255.0f);
                }

                for (int a = 0; a < width; a++) {
                    source.setGray(a, i, result[i][a]);
                }
            }
        } else {
            MatrixSource gray = new MatrixSource(source);

            Grayscale gs = new Grayscale(algorithm);
            // It is not OneBandSource
            gs.apply(gray);

            for (int i = 0; i < height; i++) {

                int iMin = Math.max(0, i - blockRadius);
                int iMax = Math.min(height, i + blockRadius + 1);
                int h = iMax - iMin;

                int jMin = Math.max(0, -blockRadius);
                int jMax = Math.min(width - 1, blockRadius);

                int[] hist = new int[bins + 1];
                int[] clippedHist = new int[bins + 1];

                for (int k = iMin; k < iMax; k++) {
                    for (int l = jMin; l < jMax; l++) {
                        ++hist[roundPositive(gray.getGray(l, k) / 255.0f * bins)];
                    }
                }

                for (int j = 0; j < width; j++) {
                    int v = roundPositive(gray.getGray(j, i) / 255.0f * bins);

                    int xMin = Math.max(0, j - blockRadius);
                    int xMax = j + blockRadius + 1;
                    int w = Math.min(width, xMax) - xMin;
                    int n = h * w;

                    int limit = (int) (slope * n / bins + 0.5f);

                    /* remove left behind values from histogram */
                    if (xMin > 0) {
                        int xMin1 = xMin - 1;
                        for (int yi = iMin; yi < iMax; ++yi) {
                            --hist[roundPositive(gray.getGray(xMin1, yi) / 255.0f * bins)];
                        }
                    }

                    /* add newly included values to histogram */
                    if (xMax <= width) {
                        int xMax1 = xMax - 1;
                        for (int yi = iMin; yi < iMax; ++yi) {
                            ++hist[roundPositive(gray.getGray(xMax1, yi) / 255.0f * bins)];
                        }
                    }

                    System.arraycopy(hist, 0, clippedHist, 0, hist.length);
                    int clippedEntries = 0, clippedEntriesBefore;
                    do {
                        clippedEntriesBefore = clippedEntries;
                        clippedEntries = 0;
                        for (int z = 0; z <= bins; ++z) {
                            int d = clippedHist[z] - limit;
                            if (d > 0) {
                                clippedEntries += d;
                                clippedHist[z] = limit;
                            }
                        }

                        int d = clippedEntries / (bins + 1);
                        int m = clippedEntries % (bins + 1);
                        for (int z = 0; z <= bins; ++z)
                            clippedHist[z] += d;

                        if (m != 0) {
                            int s = bins / m;
                            for (int z = 0; z <= bins; z += s)
                                ++clippedHist[z];
                        }
                    }
                    while (clippedEntries != clippedEntriesBefore);

                    /* build cdf of clipped histogram */
                    int hMin = bins;
                    for (int z = 0; z < hMin; ++z) {
                        if (clippedHist[z] != 0) hMin = z;
                    }

                    int cdf = 0;
                    for (int z = hMin; z <= v; ++z) {
                        cdf += clippedHist[z];
                    }

                    int cdfMax = cdf;
                    for (int z = v + 1; z <= bins; ++z) {
                        cdfMax += clippedHist[z];
                    }

                    int cdfMin = clippedHist[hMin];

                    result[i][j] = roundPositive((cdf - cdfMin) / (float) (cdfMax - cdfMin) * 255.0f);
                }

                for (int a = 0; a < width; a++) {
                    float s = (float) result[i][a] / (float) gray.getGray(a, i);

                    float r = ColorHelper.clamp(roundPositive(s * source.getR(a, i)));
                    float g = ColorHelper.clamp(roundPositive(s * source.getG(a, i)));
                    float b = ColorHelper.clamp(roundPositive(s * source.getB(a, i)));

                    int rgb = ColorHelper.getRGB((int) r, (int) g, (int) b);

                    source.setRGB(a, i, rgb);
                }
            }
        }
        return source;
    }
801072
public static DataSource createDataSource(String source){
		String typeAndConfig = configuration.getProperty(source);
		if (typeAndConfig == null){
			log.error("No configuration for data source: " + source);
			return null;
		}
		String[] typeAndConfigArray = typeAndConfig.split(DELIMITORS, 2);
		if (typeAndConfigArray.length < 2){
			log.error("Wrong configuration format for data source '" + source + "': " + typeAndConfig);
			return null;
		}
		String type = typeAndConfigArray[0];
		String config = typeAndConfigArray[1];
		return createDataSource(source, type, config);
	}
368621
public ImmutableListMultimap<Symbol, EDLMention> loadEDLMentionsByDocFrom(CharSource source) throws IOException {
    final ImmutableList<EDLMention> edlMentions = loadEDLMentionsFrom(source);
    final ImmutableListMultimap.Builder<Symbol, EDLMention> byDocs =
        ImmutableListMultimap.<Symbol, EDLMention>builder()
            .orderKeysBy(SymbolUtils.byStringOrdering());
    for (final EDLMention edlMention : edlMentions) {
      byDocs.put(edlMention.documentID(), edlMention);
    }
    return byDocs.build();
  }
1032467
private static void setPropertyFromSourceBitmap(Bitmap source, Bitmap destination) {
    // The new bitmap was created from a known bitmap source so assume that
    // they use the same density
    destination.setDensity(source.getDensity());
    if (Build.VERSION.SDK_INT >= 12) {
      destination.setHasAlpha(source.hasAlpha());
    }

    if (Build.VERSION.SDK_INT >= 19) {
      destination.setPremultiplied(source.isPremultiplied());
    }
  }
456786
protected CoverageDataSourcePixel getXSourceMinAndMax(float source) {

		int floor = (int) Math.floor(source);
		float valueLocation = getXEncodedLocation(floor,
				griddedCoverage.getGridCellEncodingType());

		CoverageDataSourcePixel pixel = getSourceMinAndMax(source, floor,
				valueLocation);
		return pixel;
	}
1343403
private <T> Collection<Integer> transformSource(SourceTransformation<T> source) {
		String slotSharingGroup = determineSlotSharingGroup(source.getSlotSharingGroup(), Collections.emptyList());

		streamGraph.addSource(source.getId(),
				slotSharingGroup,
				source.getCoLocationGroupKey(),
				source.getOperator(),
				null,
				source.getOutputType(),
				"Source: " + source.getName());
		if (source.getOperator().getUserFunction() instanceof InputFormatSourceFunction) {
			InputFormatSourceFunction<T> fs = (InputFormatSourceFunction<T>) source.getOperator().getUserFunction();
			streamGraph.setInputFormat(source.getId(), fs.getFormat());
		}
		streamGraph.setParallelism(source.getId(), source.getParallelism());
		streamGraph.setMaxParallelism(source.getId(), source.getMaxParallelism());
		return Collections.singleton(source.getId());
	}
688838
public static ImageInfo read(ByteSource byteSource) throws IOException {
        try (InputStream in = byteSource.openStream()) {
            return read(in);
        }
    }
590235
public JRBandDataDataSource subDataSource(String bandName) {
        if (containsVisitedBand(bandName))
            return null;

        BandData newParentBand = createNewBand(bandName);

        currentBand = root;
        currentIterator = root.getChildrenList().iterator();
        visitedBands.put(root, currentIterator);

        return new JRBandDataDataSource(newParentBand);
    }
357972
public function createFromSource()
    {
        /**
         * A work-around for some improperly formatted, but
         * usable JPEGs; known to be produced by Samsung
         * smartphones' front-facing cameras.
         *
         * @see    https://bugs.php.net/bug.php?id=72404
         */
        ini_set('gd.jpeg_ignore_warning', 1);

        $mime = $this->sourceImageFile->getMime();
        $mime = is_array($mime) ? $mime[ 0 ] : $mime;

        try {
            switch ($mime) {
                case 'image/jpg':
                case 'image/jpeg':
                    $this->sourceImageResource = imagecreatefromjpeg($this->sourceImageFile->getRealPath());
                    break;

                case 'image/gif':
                    $this->sourceImageResource = imagecreatefromgif($this->sourceImageFile->getRealPath());
                    break;

                case 'image/png':
                case 'image/x-png':
                    $this->sourceImageResource = imagecreatefrompng($this->sourceImageFile->getRealPath());
                    break;
            }

            // Convert pallete images to true color images
            imagepalettetotruecolor($this->sourceImageResource);
        } catch (\Exception $e) {

        }
    }
816453
public static byte[] dropUTF8BOM(final byte[] source) {
        if (source == null) {
            return null;
        }
        if (source.length < 3) {
            return source;
        }
        if ((source[0] == (byte) 0xef) && (source[1] == (byte) 0xbb) && (source[2] == (byte) 0xbf)) {
            return Arrays.copyOfRange(source, 3, source.length);
        }
        return source;
    }
1348915
private function loadResourceFromType($source)
    {

        $mime = null;
        extract(getimagesize($source));

        $fn = sprintf('imagecreatefrom%s', $type = substr($mime, strpos($mime, '/') + 1));

        if (!function_exists($fn)) {
            $this->error = sprintf('%s is not a supported image type', $mime);
            $this->clean();

            throw new \InvalidArgumentException(sprintf('Unsupported image format %s', $mime));
        }

        $this->source = $this->loader->load($source);
        $this->outputType = $mime;

        return call_user_func($fn, $this->source);
    }
1250678
public char[] prepareSource(char[] source) {
        char[] src = new char[source.length + 2];
        System.arraycopy(source, 0, src, 0, source.length);
        src[source.length] = '\n';
        src[source.length + 1] = '\n';
        return src;
    }
241044
public static ByteBufFlux fromString(Publisher<? extends String> source) {
		return fromString(source, Charset.defaultCharset(), ByteBufAllocator.DEFAULT);
	}
1137691
public static InputSource sourceToInputSource(Source source) {

        if (source instanceof SAXSource) {
            return ((SAXSource) source).getInputSource();
        } else if (source instanceof StreamSource) {
            StreamSource ss      = (StreamSource) source;
            InputSource  isource = new InputSource(ss.getSystemId());

            isource.setByteStream(ss.getInputStream());
            isource.setCharacterStream(ss.getReader());
            isource.setPublicId(ss.getPublicId());

            return isource;
        } else {
            return null;
        }
    }
397302
public static BufferedImage toImage(BitMatrix matrix, int foreColor, int backColor) {
		final int width = matrix.getWidth();
		final int height = matrix.getHeight();
		BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
		for (int x = 0; x < width; x++) {
			for (int y = 0; y < height; y++) {
				image.setRGB(x, y, matrix.get(x, y) ? foreColor : backColor);
			}
		}
		return image;
	}
1152311
public static BufferedImage convertToBufferedImage(Image img) {
        BufferedImage buff = createCompatibleTranslucentImage(
                img.getWidth(null), img.getHeight(null));
        Graphics2D g2 = buff.createGraphics();

        try {
            g2.drawImage(img, 0, 0, null);
        } finally {
            g2.dispose();
        }

        return buff;
    }
907018
@Override
    public String getSource() throws WidgetException {
        try {
            return getAttribute("src");
        } catch (Exception e) {
            throw new WidgetException("Error while fetching image source", getByLocator(), e);
        }
    }