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.260)(p.261)LISTING 10.2 <strong>Java</strong> code to perform connected region labelling, taken from theRegionLabelOp class.public Buffered<strong>Image</strong> filter(Buffered<strong>Image</strong> src, Buffered<strong>Image</strong> dest) {check<strong>Image</strong>(src);if (dest == null)dest = createCompatibleDest<strong>Image</strong>(src, null);width = src.getWidth();height = src.getHeight();WritableRaster in = src.copyData(null);WritableRaster out = dest.getRaster();}int n = 1;for (int y = 0; y < height; ++y)for (int x = 0; x < width; ++x)if (in.getSample(x, y, 0) > 0) {label(in, out, x, y, n);++n;if (n > MAX_REGIONS)return dest;}return dest;private void label(WritableRaster in, WritableRaster out,- 65 -