e665. 在图像中过滤三元色
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. 在图像中过滤三元色的更多相关文章
- 【算法随记五】使用FFT变换自动去除图像中严重的网纹。
这个课题在很久以前就已经有所接触,不过一直没有用代码去实现过.最近买了一本<机器视觉算法与应用第二版>书,书中再次提到该方法:使用傅里叶变换进行滤波处理的真正好处是可以通过使用定制的滤波器 ...
- 如何在URL筛选管理器中过滤不需要的URL
互联网可以说是一把名副其实的双刃剑.一方面其可以提高工作效率.给企业提供充分的资源;另一方面如果管理不严,也会带来很多的隐患.如员工在上班时间玩游戏.炒股等等.为此现在很多企业希望对员工的网络行为进行 ...
- android Log 等级以及在Android Studio 的Logcat中过滤方法
Log等级 等级越高,问题越严重. Log.e(TAG,"级别5,错误信息"); Log.e(TAG,"级别5,错误信息"); Log.w(TAG," ...
- 从视频文件中读入数据-->将数据转换为灰度图-->对图像做canny边缘检测-->将这三个结构显示在一个图像中
//从视频文件中读入数据-->将数据转换为灰度图-->对图像做canny边缘检测-->将这三个结构显示在一个图像中 //作者:sandy //时间:2015-10-10 #inclu ...
- Zybo智能小车识别图像中的文字
智能小车识别图像中的文字 [TOC] 运行平台 这次的内容是基于Xilinx公司的Zybo开发板以及其配套的Zrobot套件开发 Zybo上面的sd卡搭载了Ubuntu12.04LTS的linux版本 ...
- 访问图像中的像素[OpenCV 笔记16]
再更一发好久没更过的OpenCV,不过其实写到这个部分对计算机视觉算法有所了解的应该可以做到用什么查什么了,所以后面可能会更的慢一点吧,既然开了新坑,还是机器学习更有研究价值吧... 图像在内存中的存 ...
- Python 更改cmd中的字色
没有gui的python程序是在cmd窗口中运行的,黑色背景,灰色的字,确实很复古,不符合现代人的使用习惯-同事在用我写的小工具时,清一色的字色,看起来会没有重点性,因此我就想通过更改cmd中的字色来 ...
- Matlab实现Hough变换检測图像中的直线
Hough变换的原理: 将图像从图像空间变换至參数空间.变换公式例如以下: 变换以后,图像空间与參数空间存在下面关系: 图像空间中的一点在參数空间是一条曲线,而图像空间共线的各点相应于參数空间交于一点 ...
- 几种在shell命令行中过滤adb logcat输出的方法
我们在Android开发中总能看到程序的log日志内容充满了屏幕,而真正对开发者有意义的信息被淹没在洪流之中,让开发者无所适从,严重影响开发效率.本文就具体介绍几种在shell命令行中过滤adblog ...
随机推荐
- Oracle监听配置、数据库实例配置等
参考:http://jingyan.baidu.com/article/3aed632e7a638b70108091dd.html linux下面搞Orale参考:http://blog.sina.c ...
- Linux内存管理机制中buffer和cache的区别
Linux内存管理机制中buffer和cache的区别理解linux内存管理,需要深入了解linux内存的各个参数含义和规则,下面介绍一下Linux操作系统中内存buffer和cache的区别. Fr ...
- 使用配置hadoop中常用的Linux(ubuntu)命令
生成key: $ ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa $ cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized ...
- receiver type *** for instance message is a forward declaration
转自:http://stackoverflow.com/questions/8815200/receiver-type-for-instance-message-is-a-forward-declar ...
- java动态代理的两种方法
动态代理,有两种情况,第一种是有接口的情况下,你可以选择为jdk自带的动态代理的方式来编写程序,但你想要为一个实在的类编写动态代理的方式的话,这时候就必须选择一些开源的lib包,如cglib包,同时还 ...
- centos7 編譯 chmsee
安装libchm及相关的devel包,安装 xulrunner 及 devel 包!否则后面make的时候会出错! 到解压出来的chmsee/src目录下,找到与你系统对应的Makefile文件,我选 ...
- Python 2.7.9 Demo - 001.print_hello_world - 002.print_chinese
001.print_hello_world #!/usr/bin/python print "hello, world..."; 002.print_chinese #coding ...
- js在IE8+兼容String没有trim方法,写一个兼容ie8一下的浏览器的trim()方法
方法一: String.prototype.trim = function(){ return Trim(this);}; function LTrim(str) { var i; fo ...
- maven-gpg-plugin:1.2:sign (sign-artifacts) on project jdbc-pool: Cannot obtain passphrase in batch mode或者是Plugin execution not covered by lifecycle configuration
本解决方案转自:http://blog.csdn.net/tangximing123/article/details/21179467 执行 Maven install 时报错: Failed to ...
- redis、mysql、和php原生array数组效率对比
最近要做一个屏蔽词的功能,屏蔽词是保存在配置文件里,最开始是用php数组存储,然后查找. 后来随着屏蔽词的增多,速度明显的变慢了,于是考虑到用redis或mysql做. 于是写了一个测试,测试结果如下 ...