Need Sobel edge detection

can anyone post the Sobel edge detection
[47 byte] By [lavakusareddya] at [2007-10-3 4:35:39]
# 1

hey, there you go !!, if you have some questions about using this code, just ask =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;

}

}

dave_wizarda at 2007-7-14 22:39:22 > top of Java-index,Security,Cryptography...