Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import ij.ImagePlus;
- import ij.plugin.filter.PlugInFilter;
- import ij.process.ImageProcessor;
- public class Binomialfilter_4hp implements PlugInFilter {
- ImagePlus imp;
- public void run(ImageProcessor ip) {
- int w = ip.getWidth();
- int h = ip.getHeight();
- double [][] binomial = {{-1/256.0, -4/256.0, -6/256.0, -4/256.0, -1/256.0},
- {-4/256.0, -16/256.0, -24/256.0, -16/256.0, -4/256.0},
- {-6/256.0, -24/256.0, 220/256.0, -24/256.0, -6/256.0},
- {-4/256.0, -16/256.0, -24/256.0, -16/256.0, -4/256.0},
- {-1/256.0, -4/256.0, -6/256.0, -4/256.0, -1/256.0}
- };
- ImageProcessor copy = ip.duplicate();
- for(int u = 2; u< w-3; u++)
- {
- for (int v = 2; v < h-3; v++)
- {
- double sum = 0;
- for(int j=-2; j<=2; j++){
- for(int i = -2; i<=2; i++){
- int p = copy.getPixel(u+i, v+j);
- double c = binomial[j+2][i+2];
- sum = sum + c * p;
- }
- }
- int q = (int) sum;
- ip.putPixel(u, v, q);
- }
- }
- }
- public int setup(String arg0, ImagePlus imp) {
- return DOES_8G;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement