Java - EdgeW / EdgeH


/ Published in: Java
Save to your folder(s)



Copy this code and paste it in your HTML
  1. public BufferedImage EdgeW(BufferedImage bi)
  2. {
  3. BufferedImage buff = new BufferedImage(bi.getWidth(), bi.getHeight(), bi.getType());
  4.  
  5. Kernel kernel = new Kernel(3, 3, new float[] {
  6. -1f, 0f, 1f,
  7. -2f, 0f, 2f,
  8. -1f, 0f, 1f
  9. });
  10.  
  11. ConvolveOp op = new ConvolveOp(kernel);
  12. op.filter(bi, buff);
  13.  
  14. return buff;
  15. }
  16.  
  17.  
  18. public BufferedImage EdgeH(BufferedImage bi)
  19. {
  20. BufferedImage buff = new BufferedImage(bi.getWidth(), bi.getHeight(), bi.getType());
  21.  
  22. Kernel kernel = new Kernel(3, 3, new float[] {
  23. -1f, -2f, -1f,
  24. 0f, 0f, 0f,
  25. 1f, 2f, 1f
  26. });
  27.  
  28. ConvolveOp op = new ConvolveOp(kernel);
  29. op.filter(bi, buff);
  30.  
  31. return buff;
  32. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.