Java BufferedImage Operation changeContrast(BufferedImage img, float amount)

Here you can find the source of changeContrast(BufferedImage img, float amount)

Description

Changes the contrast of an image

License

Open Source License

Parameter

Parameter Description
img a parameter
amount a parameter

Declaration

public static BufferedImage changeContrast(BufferedImage img, float amount) 

Method Source Code

//package com.java2s;
/* Image to ZX Spec//from  w w w .  j  a va2  s.  c o  m
 * Copyright (C) 2014 Silent Software (Benjamin Brown)
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

import java.awt.image.BufferedImage;
import java.awt.image.RescaleOp;

public class Main {
    /**
     * Changes the contrast of an image
     * 
     * @param img
     * @param amount
     * @return
     */
    public static BufferedImage changeContrast(BufferedImage img, float amount) {
        if (amount == 1) {
            return img;
        }
        RescaleOp rescaleOp = new RescaleOp(amount, 0, null);
        return rescaleOp.filter(img, null);
    }
}

Related

  1. buildColorStatisticsOfImage(BufferedImage image)
  2. buildingCoordinatesInImage(BufferedImage imageSection)
  3. buildPixelAverages(BufferedImage a, Rectangle[] sectors)
  4. buildSectors(BufferedImage a, int sqrtSectors)
  5. cascadeHorizontal(final BufferedImage... images)
  6. changeImageToArray(BufferedImage bufferedImage)
  7. checkIfManyColors(BufferedImage image)
  8. checkImageMatch(BufferedImage img1, String imgName1, BufferedImage img2, String imgName2)
  9. checkImageType(BufferedImage img, String name)