Digital Image Processing (using Java)
Digital Image Processing (using Java)
Digital Image Processing (using Java)
- No tags were found...
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
(p.238)LISTING 9.2 <strong>Java</strong> implementation of Algorithm 9.1public static Buffered<strong>Image</strong> rotate(Buffered<strong>Image</strong> input, double angle){int width = input.getWidth();int height = input.getHeight();Buffered<strong>Image</strong> output = new Buffered<strong>Image</strong>(width, height, input.getType());double a0 = Math.cos(angle*Math.PI/180.0);double b0 = Math.sin(angle*Math.PI/180.0);double a1 = -b0, b1 = a0;}int rx, ry;for (int y = 0; y < height; ++y)for (int x = 0; x < width; ++x){rx = (int) Math.round(a0*x + a1*y);ry = (int) Math.round(b0*x + b1*y);if (rx >= 0 && rx < width && ry >=0 && ry < height)output.setRGB(rx, ry, input.getRGB(x,y));}return output;(p.239)- 59 -