12.07.2015 Views

Digital Image Processing (using Java)

Digital Image Processing (using Java)

Digital Image Processing (using Java)

SHOW MORE
SHOW LESS
  • 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.

LISTING 5.17 <strong>Java</strong> code to average a set of images.public static Buffered<strong>Image</strong> average (Buffered<strong>Image</strong>[] imgArray ){int n = imgArray.length;int w = imgArray[0].getWidth(); //assume that they all haveint h = imgArray[0].getHeight(); //the same dimensionsBuffered<strong>Image</strong> average =new Buffered<strong>Image</strong>(w, h, Buffered<strong>Image</strong>.TYPE_BYTE_GRAY);}for (int y = 0; y < h; ++y)for (int x=0; x < w; ++x)float sum = 0.0f;for (int I = 0; I < n; ++i)sum += imgArray[i].getRaster().getSample(x, y, 0);raster.setSample (x, y, Math.round (sum/n));}return average;(p.102)Exercise 5.71. Write a <strong>Java</strong> program that will(a) Display an image(b) Allow the user to select a region of interest (ROI)(c) Extract this ROI from the image(d) Write the ROI to a user-specified file(p.111)- 19 -

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!