Total members 11893 |It is currently Tue Nov 05, 2024 8:29 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





Image Custom Filter In java
java code
package imageviewer;

import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;
import java.awt.image.BufferedImageOp;
import java.awt.image.ConvolveOp;
import java.awt.image.Kernel;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

import javax.swing.JTextField;


public class CustomFilter extends JFrame{

/** Creates a new instance of CustomFilter */
public CustomFilter(BufferedImage buffImage) {
setTitle("Custom Filter");
setSize(400,200);
setLocation(250,250);
Orginal=buffImage;
Container cp=getContentPane();
cp.setLayout(new FlowLayout());
myPanel.setLayout(new GridLayout(5,5));

for(int i=0;i<5;i++)
for(int j=0;j<5;j++) {
myfilds[i][j]=new JTextField("0.08",5);
myPanel.add(myfilds[i][j]);
}
ok.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {

int count=0;
float foa;
for(int i=0;i<5;i++)
for(int j=0;j<5;j++) {


customfil[count] =Float.parseFloat(myfilds[i][j].getText());

count++;
}

int w =Orginal.getWidth();
int h = Orginal.getHeight();
biop = new ConvolveOp(new Kernel(dim[0][0],dim[0][1],customfil));
BufferedImage bi = new BufferedImage(w,h,Orginal.TYPE_INT_RGB);
biop.filter(Orginal,bi);
new ShowFrame(bi,"Custom Filter");
}
});
Cancel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
dispose();
}
});
cp.add(myPanel);
cp.add(ok);
cp.add(Cancel);

}
private JTextField [][] myfilds=new JTextField[5][5];
private JPanel myPanel=new JPanel();
private JButton ok=new JButton("OK");
private JButton Cancel=new JButton("Cancel");
private float[] customfil = new float[25];
private BufferedImageOp biop;
private BufferedImage Orginal;
private int dim[][] = {{5,5}};
}


Original Project :
finished-projects/image-viewer-image-processing-filters-noise-enhancements-t639.html



_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : Image Custom Filter In Java
 Image Noise Filter in Java     -  
 apply mean filter to image     -  
 Median filter to image     -  
 apply laplacian filter to image     -  
 Applying canny filter to image     -  
 apply robert filter to image     -  
 apply sobel filter to image     -  
 applying wiener filter to image     -  
 apply prewitt filter to image     -  
 rank order filter effects on image     -  



Topic Tags

Java Image






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com