public static BufferedImage getProcessedImage(BufferedImage bi) {
BufferedImageOp bio = getEdgeDetectOp();
BufferedImage bi = process(bi, bio);
return bi;
}
public static BufferedImage process (BufferedImage srcImage,
BufferedImageOp op) {
BufferedImage destImage = op.createCompatibleDestImage(srcImage,
srcImage.getColorModel());
destImage = op.filter(srcImage, destImage);
return destImage;
}
public static ConvolveOp getEdgeDetectOp(){
float matrix[] = {
-1.0f, -1.0f, -1.0f,
-1.0f, 8.0f, -1.0f,// 8 or 9+ for sharper edges
-1.0f, -1.0f, -1.0f
};
Kernel kernel = new Kernel(3, 3, matrix);
return getConvolveOp(kernel);
}
public static ConvolveOp getConvolveOp(Kernel kernel) {
RenderingHints hints =
new RenderingHints(RenderingHints.KEY_RENDERING,
RenderingHints.VALUE_RENDER_QUALITY);
ConvolveOp op = new ConvolveOp(kernel,
ConvolveOp.EDGE_NO_OP,
hints);
return op;
}
regards
I thought you said edge detection. If you want to use something like Freeman chains, for instance to outline contours in an image, look at
http://www.cs.mcgill.ca/~jsatta/pr644/freeman/applet.html
to see if that`s helpful. If it is you can download the source
http://www.cs.mcgill.ca/~jsatta/pr644/freeman/org/junaed/comp644/sources/freeman.zip
regards
i need edge detection using
EDGE DETECTION METHODS:-
SOBEL operators
Laplacian-of-Gaussian (LoG) filter
Castan edge operators, Gradient method
Castan edge operators, Zero-crossings method
PSEUDO-LAPLACE operators
Morphological Edge operator
Difference-of-Gaussian (DoG) filter
KIRSCH operators
Deriche Edge Operator
Contra-harmonic Filter
i need code for atleast any two of them or best of them.can u clarify about my previous question i.e have u presented the complete edge detection code in u'r first reply.iam new to java platform if u don't mine can u give the complete code from IMPORT to LAST SENTENCE.PLEASE HELP ME
hey! if u r looking for sobel edge detection code, there u go (the code is not commented, so if u want to ask something, just do it) =D
import java.applet.*;
import java.awt.*;
import java.awt.image.*;
import java.net.*;
import java.util.*;
import java.io.*;
public class Sobel extends Thread{
private int d_w;
private int d_h;
private int[]dest_1d;
public int[] aplicar_sobel(int[] src_1d, int width, int height, double sobscale,float offsetval){
int i_w = width;
int i_h = height;
d_w = width;
d_h = height;
dest_1d = new int[d_w * d_h];
for(int i=0;i<src_1d.length;i++){
try {
int bl = 0x000000ff;
int a = src_1d[i] & bl;
int b = src_1d[i+ 1] & bl;
int c = src_1d[i+ 2] & bl;
int d = src_1d[i + i_w] & bl;
int e = src_1d[i + i_w + 2] & bl;
int f = src_1d[i + 2*i_w ] & bl;
int g = src_1d[i + 2*i_w + 1] & bl;
int h = src_1d[i + 2*i_w + 2] & bl;
int hor = (a+d+f) - (c+e+h);
if (hor >< 0) hor = -hor;
int vert = (a+b+c) - (f+g+h);
if (vert < 0) vert = -vert;
short gc = (short) (sobscale * (hor + vert));
gc = (short) (gc + offsetval);
if (gc > 255) gc = 255;
dest_1d[i] = 0xff000000 | gc<<16 | gc<<8 | gc;
if (((i+3)%i_w)==0) {
dest_1d[i] = 0;
dest_1d[i+1] = 0;
dest_1d[i+2] = 0;
i+=3;
}
} catch (ArrayIndexOutOfBoundsException e) {
i = src_1d.length;
}
}
return dest_1d;
}
}