「图形处理java」图形处理器丛林拼图
今天给各位分享图形处理java的知识,其中也会对图形处理器丛林拼图进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!
本文目录一览:
- 1、《JAVA数字图像处理》pdf下载在线阅读全文,求百度网盘云资源
- 2、JAVA Applet 程序的图形处理
- 3、java 关于图形界面和事件处理
- 4、在java语言中处理图形用户界面的类库主要是java.awt包和什么包
- 5、JAVA关于图像处理问题
- 6、java适合做图像处理吗?
《JAVA数字图像处理》pdf下载在线阅读全文,求百度网盘云资源
《JAVA数字图像处理》百度网盘pdf最新全集下载:
链接:
?pwd=f8sq 提取码: f8sq
简介:在开始本书内容之前,笔者假设你已经有了面向对象语言编程的基本概念,了解Java语言的基本语法与特征,原因在于本书的所有源代码都是基于Java语言实现的,而且是基于Java开发环境运行与演示所有图像处理算法的。本书第1章到第3章是为了帮助读者了解与掌握Java图形与GUI编程的基本知识与概念而写的。本章主要介绍Java GUI编程中基本的图形知识,针对GU1编程,Java语言提供了两套几乎并行的API,分别是Swing与AWT。早期的Java GUJ编程中主要使用AWT的相关组件,但是AWT的功能并不是十分强大,而且严重依赖本地接口。于是在Java 1.3及后续版本中引入了Swing工具实现GUl编程,Swing中的组件大多数都是基于纯Java语言实现的,而不是通过本地组件实现的,所以它们是轻量级的GUI组件,同时Swing对图形与图像的支持操作也有很大的提高与增强。如何区分AWT组件与Swing组件?一个简单而且相当直观的方法是看Class的名称,Swing的组件大多数带有大写的前缀字母J。
JAVA Applet 程序的图形处理
才疏学浅。只学到了:g.drawOval(30,30,70,70);
public abstract void drawOval(int x,int y,int width,int height):参数x,y用来指定椭圆的位置。参数width,height分别用来指定椭圆的短轴和长轴的长度。特殊的,当长轴和短轴相等时,即可绘制成圆。希望对你有所帮助。
java 关于图形界面和事件处理
package client;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JTextField;
import javax.swing.event.AncestorListener;
public class Test extends JFrame{
private JTextField text;
private JButton button;
public Test(){
super();
this.setSize(new Dimension(250,100));
JPanel panel = new JPanel();
panel.setSize(new Dimension(250,100));
text = new JTextField();
text.setPreferredSize(new Dimension(150,30));
button = new JButton("确认");
button.setPreferredSize(new Dimension(60,30));
button.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent e) {
String s = text.getText();
if(s!=null){
double d = Double.parseDouble(s);
double result = d*d;
text.setText(String.valueOf(result));
}
}
});
panel.add(text);
panel.add(button);
this.setContentPane(panel);
this.setVisible(true);
}
public static void main(String[] args) {
new Test();
}
}
在java语言中处理图形用户界面的类库主要是java.awt包和什么包
答:javax.swing包 注意这里是javax 不是java
图形界面最常见的导入下面三个
import java.awt.*;
import java.awt.event.*;//事件处理的相关包
import javax.swing.*;
JAVA关于图像处理问题
读取控制台输入的路径
判断文件是否存在
Y: - 2
N:在命令行输出"Sorry, I cannot find that file."并退出
读取图片
分析图片像素,按要求将多余的像素截掉
创建一个新图片,像素为原图片的1/4大小
合并像素,将4个像素通过给定的条件计算RGB值合并为1个像素
输出图片,路径为原始图片路径,文件名按要求做处理
不知仁兄的水平在啥程度,整个流程如上列出,哪一步不明确的可以追问
java适合做图像处理吗?
Java图像处理技巧四则
下面代码中用到的sourceImage是一个已经存在的Image对象
图像剪切
对于一个已经存在的Image对象,要得到它的一个局部图像,可以使用下面的步骤:
//import java.awt.*;
//import java.awt.image.*;
Image croppedImage;
ImageFilter cropFilter;
CropFilter =new CropImageFilter(25,30,75,75); //四个参数分别为图像起点坐标和宽高,即CropImageFilter(int x,int y,int width,int height),详细情况请参考API
CroppedImage= Toolkit.getDefaultToolkit().createImage(new FilteredImageSource(sourceImage.getSource(),cropFilter));
如果是在Component的子类中使用,可以将上面的Toolkit.getDefaultToolkit().去掉。FilteredImageSource是一个ImageProducer对象。
图像缩放
对于一个已经存在的Image对象,得到它的一个缩放的Image对象可以使用Image的getScaledInstance方法:
Image scaledImage=sourceImage. getScaledInstance(100,100, Image.SCALE_DEFAULT); //得到一个100X100的图像
Image doubledImage=sourceImage. getScaledInstance(sourceImage.getWidth(this)*2,sourceImage.getHeight(this)*2, Image.SCALE_DEFAULT); //得到一个放大两倍的图像,这个程序一般在一个swing的组件中使用,而类Jcomponent实现了图像观察者接口ImageObserver,所有可以使用this。
//其它情况请参考API
灰度变换
下面的程序使用三种方法对一个彩色图像进行灰度变换,变换的效果都不一样。一般而言,灰度变换的算法是将象素的三个颜色分量使用R*0.3+G*0.59+ B*0.11得到灰度值,然后将之赋值给红绿蓝,这样颜色取得的效果就是灰度的。另一种就是取红绿蓝三色中的最大值作为灰度值。java核心包也有一种算法,但是没有看源代码,不知道具体算法是什么样的,效果和上述不同。
/* GrayFilter.java*/
/*@author:cherami */
/*email:cherami@163.net*/
import java.awt.image.*;
public class GrayFilter extends RGBImageFilter {
int modelStyle;
public GrayFilter() {
modelStyle=GrayModel.CS_MAX;
canFilterIndexColorModel=true;
}
public GrayFilter(int style) {
modelStyle=style;
canFilterIndexColorModel=true;
}
public void setColorModel(ColorModel cm) {
if (modelStyle==GrayModel
else if (modelStyle==GrayModel
}
public int filterRGB(int x,int y,int pixel) {
return pixel;
}
}
/* GrayModel.java*/
/*@author:cherami */
/*email:cherami@163.net*/
import java.awt.image.*;
public class GrayModel extends ColorModel {
public static final int CS_MAX=0;
public static final int CS_FLOAT=1;
ColorModel sourceModel;
int modelStyle;
public GrayModel(ColorModel sourceModel) {
super(sourceModel.getPixelSize());
this.sourceModel=sourceModel;
modelStyle=0;
}
public GrayModel(ColorModel sourceModel,int style) {
super(sourceModel.getPixelSize());
this.sourceModel=sourceModel;
modelStyle=style;
}
public void setGrayStyle(int style) {
modelStyle=style;
}
protected int getGrayLevel(int pixel) {
if (modelStyle==CS_MAX) {
return Math.max(sourceModel.getRed(pixel),Math.max(sourceModel.getGreen(pixel),sourceModel.getBlue(pixel)));
}
else if (modelStyle==CS_FLOAT){
return (int)(sourceModel.getRed(pixel)*0.3+sourceModel.getGreen(pixel)*0.59+sourceModel.getBlue(pixel)*0.11);
}
else {
return 0;
}
}
public int getAlpha(int pixel) {
return sourceModel.getAlpha(pixel);
}
public int getRed(int pixel) {
return getGrayLevel(pixel);
}
public int getGreen(int pixel) {
return getGrayLevel(pixel);
}
public int getBlue(int pixel) {
return getGrayLevel(pixel);
}
public int getRGB(int pixel) {
int gray=getGrayLevel(pixel);
return (getAlpha(pixel)24)+(gray16)+(gray8)+gray;
}
}
如果你有自己的算法或者想取得特殊的效果,你可以修改类GrayModel的方法getGrayLevel()。
色彩变换
根据上面的原理,我们也可以实现色彩变换,这样的效果就很多了。下面是一个反转变换的例子:
/* ReverseColorModel.java*/
/*@author:cherami */
/*email:cherami@163.net*/
import java.awt.image.*;
public class ReverseColorModel extends ColorModel {
ColorModel sourceModel;
public ReverseColorModel(ColorModel sourceModel) {
super(sourceModel.getPixelSize());
this.sourceModel=sourceModel;
}
public int getAlpha(int pixel) {
return sourceModel.getAlpha(pixel);
}
public int getRed(int pixel) {
return ~sourceModel.getRed(pixel);
}
public int getGreen(int pixel) {
return ~sourceModel.getGreen(pixel);
}
public int getBlue(int pixel) {
return ~sourceModel.getBlue(pixel);
}
public int getRGB(int pixel) {
return (getAlpha(pixel)24)+(getRed(pixel)16)+(getGreen(pixel)8)+getBlue(pixel);
}
}
/* ReverseColorModel.java*/
/*@author:cherami */
/*email:cherami@163.net*/
import java.awt.image.*;
public class ReverseFilter extends RGBImageFilter {
public ReverseFilter() {
canFilterIndexColorModel=true;
}
public void setColorModel(ColorModel cm) {
substituteColorModel(cm,new ReverseColorModel(cm));
}
public int filterRGB(int x,int y,int pixel) {
return pixel;
}
}
要想取得自己的效果,需要修改ReverseColorModel.java中的三个方法,getRed、getGreen、getBlue。
下面是上面的效果的一个总的演示程序。
/*GrayImage.java*/
/*@author:cherami */
/*email:cherami@163.net*/
import java.awt.*;
import java.awt.image.*;
import javax.swing.*;
import java.awt.color.*;
public class GrayImage extends JFrame{
Image source,gray,gray3,clip,bigimg;
BufferedImage bimg,gray2;
GrayFilter filter,filter2;
ImageIcon ii;
ImageFilter cropFilter;
int iw,ih;
public GrayImage() {
ii=new ImageIcon(\"images/11.gif\");
source=ii.getImage();
iw=source.getWidth(this);
ih=source.getHeight(this);
filter=new GrayFilter();
filter2=new GrayFilter(GrayModel.CS_FLOAT);
gray=createImage(new FilteredImageSource(source.getSource(),filter));
gray3=createImage(new FilteredImageSource(source.getSource(),filter2));
cropFilter=new CropImageFilter(5,5,iw-5,ih-5);
clip=createImage(new FilteredImageSource(source.getSource(),cropFilter));
bigimg=source.getScaledInstance(iw*2,ih*2,Image.SCALE_DEFAULT);
MediaTracker mt=new MediaTracker(this);
mt.addImage(gray,0);
try {
mt.waitForAll();
} catch (Exception e) {
}
图形处理java的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于图形处理器丛林拼图、图形处理java的信息别忘了在本站进行查找喔。
发布于:2022-12-02,除非注明,否则均为
原创文章,转载请注明出处。