This example demonstrates how to create a filter that can modify any of the RGB pixel values in an image.

    // This filter removes all but the red values in an image
class GetRedFilter extends RGBImageFilter {
public GetRedFilter() {
// When this is set to true, the filter will work with images
// whose pixels are indices into a color table (IndexColorModel).
// In such a case, the color values in the color table are filtered.
canFilterIndexColorModel = true;
} // This method is called for every pixel in the image
public int filterRGB(int x, int y, int rgb) {
if (x == -1) {
// The pixel value is from the image's color table rather than the image itself
}
// Return only the red component
return rgb & 0xffff0000;
}
}

Here's some code that uses the filter:

    // Get image
Image image = new ImageIcon("image.gif").getImage(); // Create the filter
ImageFilter filter = new GetRedFilter();
FilteredImageSource filteredSrc = new FilteredImageSource(image.getSource(), filter); // Create the filtered image
image = Toolkit.getDefaultToolkit().createImage(filteredSrc);
Related Examples

e665. 在图像中过滤三元色的更多相关文章

  1. 【算法随记五】使用FFT变换自动去除图像中严重的网纹。

    这个课题在很久以前就已经有所接触,不过一直没有用代码去实现过.最近买了一本<机器视觉算法与应用第二版>书,书中再次提到该方法:使用傅里叶变换进行滤波处理的真正好处是可以通过使用定制的滤波器 ...

  2. 如何在URL筛选管理器中过滤不需要的URL

    互联网可以说是一把名副其实的双刃剑.一方面其可以提高工作效率.给企业提供充分的资源;另一方面如果管理不严,也会带来很多的隐患.如员工在上班时间玩游戏.炒股等等.为此现在很多企业希望对员工的网络行为进行 ...

  3. android Log 等级以及在Android Studio 的Logcat中过滤方法

    Log等级 等级越高,问题越严重. Log.e(TAG,"级别5,错误信息"); Log.e(TAG,"级别5,错误信息"); Log.w(TAG," ...

  4. 从视频文件中读入数据-->将数据转换为灰度图-->对图像做canny边缘检测-->将这三个结构显示在一个图像中

    //从视频文件中读入数据-->将数据转换为灰度图-->对图像做canny边缘检测-->将这三个结构显示在一个图像中 //作者:sandy //时间:2015-10-10 #inclu ...

  5. Zybo智能小车识别图像中的文字

    智能小车识别图像中的文字 [TOC] 运行平台 这次的内容是基于Xilinx公司的Zybo开发板以及其配套的Zrobot套件开发 Zybo上面的sd卡搭载了Ubuntu12.04LTS的linux版本 ...

  6. 访问图像中的像素[OpenCV 笔记16]

    再更一发好久没更过的OpenCV,不过其实写到这个部分对计算机视觉算法有所了解的应该可以做到用什么查什么了,所以后面可能会更的慢一点吧,既然开了新坑,还是机器学习更有研究价值吧... 图像在内存中的存 ...

  7. Python 更改cmd中的字色

    没有gui的python程序是在cmd窗口中运行的,黑色背景,灰色的字,确实很复古,不符合现代人的使用习惯-同事在用我写的小工具时,清一色的字色,看起来会没有重点性,因此我就想通过更改cmd中的字色来 ...

  8. Matlab实现Hough变换检測图像中的直线

    Hough变换的原理: 将图像从图像空间变换至參数空间.变换公式例如以下: 变换以后,图像空间与參数空间存在下面关系: 图像空间中的一点在參数空间是一条曲线,而图像空间共线的各点相应于參数空间交于一点 ...

  9. 几种在shell命令行中过滤adb logcat输出的方法

    我们在Android开发中总能看到程序的log日志内容充满了屏幕,而真正对开发者有意义的信息被淹没在洪流之中,让开发者无所适从,严重影响开发效率.本文就具体介绍几种在shell命令行中过滤adblog ...

随机推荐

  1. python标准库介绍——1 os详解

    == os 模块 == ``os`` 模块为许多操作系统函数提供了统一的接口. 这个模块中的大部分函数通过对应平台相关模块实现, 比如 ``posix`` 和 ``nt. os`` 模块会在第一次导入 ...

  2. unity3d prefab

    用prefab创建的实例,其position/rotation/scale并不会随prefab的position/rotation/scale修改而更新,其它属性才会. 不过如果prefab的某个实例 ...

  3. vmware esxi 过期,激活

    首先我们打开vSphere Client,登录esxi主机 他会提示你,说你的esxi主机的评估期还剩多长时间 我们现在去激活,我们下载esxi的注册机 然后点击配置--->已获许可的功能--- ...

  4. C# FUNC 应用

    using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Func ...

  5. Test for Required Behavior, Not Incidental Behavior

    Test for Required Behavior, Not Incidental Behavior Kevlin Henney A COMMON PITFALL IN TESTING is to ...

  6. ORACLE 多列合并成一行数据 WM_CONCAT函数以及REPLACE

    WM_CONCAT()方法 注意字符长度 SELECT BERTHCODE,tpf.freedatetype, ( SELECT WM_CONCAT(SBPT.PARKSTIME||'~'||SBPT ...

  7. 【Javascript】Javascript横向/纵向合并单元格TD

    > 需求是这样滴(>_<) 在报表系统中,涉及“HTML的TD单元格的合并”恐怕为数不少. 比如,从DB查得数据并经过后台的整理后,可能是这样的: Table1     JOB TO ...

  8. js解析url参数如http://www.taobao.com/index.php?key0=21&key1=你哈&(获取key0和key1的值)

    function parseQueryString(url) { var pos; var obj = {}; if ((pos = url.indexOf("?")) != -1 ...

  9. LeetCode: Rotate Image 解题报告

    Rotate ImageYou are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees ( ...

  10. sqlachemy中批量删除的问题

    db.session.query(Article).filter(Article.id.in_(items)).delete() 报错: sqlalchemy.exc.InvalidRequestEr ...