File file = new File("F:/firefox.png");
File destFile = new File("F:/pic/" + System.currentTimeMillis() + ".png");
BufferedImage image = ImageIO.read(file);
BufferedImage destImage = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_ARGB);
ColorConvertOp cco = new ColorConvertOp(ColorSpace.getInstance(ColorSpace.CS_GRAY), null);
cco.filter(image, destImage);
ImageIO.write(destImage, "png", destFile);

原图:

处理后:

JAVA彩色图片变灰处理的更多相关文章

  1. CSS使图片变灰

    为了悼念,各大网站都纷纷将自己的站点颜色调灰,就连图片也一样,到底如何实现的呢,请看下面的代码. 〈img src="http://hovertree.com/hvtimg/201512/f ...

  2. c# winform 把彩色图片转换为灰色的图片,变灰,灰度图片,速度很快,safe,unsafe

    把彩色图片转换为灰色的图片,直接用.net接口遍历每个像素点转换的效率非常低,800K的图片65万像素我的电脑要用5分钟,而用了unsafe,速度提高了几千倍,同样的图片只用了0.几秒 附一个常用的遍 ...

  3. NGUI 图片变灰

    效果图 1.先准备好一个变灰shader.代码如下 Shader "Custom/Gray" { Properties { _MainTex ("Base (RGB), ...

  4. cocos2d-x图片变灰或者变亮

    //根据现有CCSprite,变亮和变灰 CCSprite* FlyLeaf::graylightWithCCSprite(CCSprite* oldSprite,bool isLight) {    ...

  5. java 让图片变黑白

    import java.awt.Image;import java.awt.color.ColorSpace;import java.awt.image.BufferedImage;import ja ...

  6. Unity图片变灰的方式

    http://www.tuicool.com/articles/Vruuqme NGUI中的Button差点儿是最经常使用到的控件之中的一个,而且能够组合各种组件(比方UIButtonColor,UI ...

  7. asp.net(c#)将彩色图片变灰阶图片

    代码如下: using System; using System.Collections; using System.Configuration; using System.Data; using S ...

  8. 图片变灰css3

    -webkit-filter: grayscale(100%); -moz-filter: grayscale(100%); -ms-filter: grayscale(100%); -o-filte ...

  9. 为什么使彩色图变灰RGB的权重会固定(R:0.299 G:0.587 B:0.114)?

    人眼对绿色的敏感度最高,对红色的敏感度次之,对蓝色的敏感度最低,因此使用不同的权重将得到比较合理的灰度图像.根据实验和理论推导得出以下数值 R: 0.299. G:  0.587. B: 0.114.

随机推荐

  1. grails框架中读取txt文件内容将内容转换为json格式,出现异常Exception in thread "main" org.json.JSONException: A JSONObject text must begin with '{' at character 1 of [...]

    Exception in thread "main" org.json.JSONException: A JSONObject text must begin with '{' a ...

  2. 002.AngularJs调用Restful实现CRUD

    本节我们主要给大家介绍AngularJs如何调用Restful,实现数据的CRUD. 主要用到的技术: 后端:ASP.NET WebApi + SQLServer2008 前端:AngularJs,B ...

  3. php解析json数据

    <?php $data; $data.="["; for ($i=0;$i<20;$i++) { $data.="{"; $data.=" ...

  4. location对象,将url解析为独立片段search属性截取传递的参数

    通过location对象的search属性截取字符串传递过来的参数 search ?item=hello&name=auto&age=25 返回url中传递的参数,以?开头 funct ...

  5. LeetCode Maximum Product Subarray(枚举)

    LeetCode Maximum Product Subarray Description Given a sequence of integers S = {S1, S2, . . . , Sn}, ...

  6. SpringMVC入门2-注解开发

    Spring MVC 注解开发 <context:component-scan base-package="com.controls" /> Springmvc的扫描器 ...

  7. C语言学习笔记--结构体

    结构体定义三种方式: #include<stdio.h> //第一种定义方法 struct point { int x; int y; }; struct point p1,p2; //第 ...

  8. out.print和out.write方法

    <%@ page language="java" import="java.util.*" %> <%@ page pageEncoding= ...

  9. zoj 3785 What day is that day?

    http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5272 打表找规律. #include <cstdio> #incl ...

  10. Ubiquitous Religions

    http://poj.org/problem?id=2524 这道题就是并查集. #include<cstdio> #include<cstring> #include< ...