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...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

public LookupOp(LookupTable table, RenderingHints hints)ex: byte[] table = new byte[256];for (int I = 0; I < 256; ++i)table[i] = (byte) (255-i);ByteLookupTable invertTable = new ByteLookupTable(0, table);LookupOp invertOp = new LookupOp(invertTable, null);Buffered<strong>Image</strong> inverted<strong>Image</strong> = invertOp.filter(image, null);(p.116)LISTING 6.3 A <strong>Java</strong> class to perform mapping of grey levels in an image.package com.pearsoneduc.ip.op;import java.awt.image.*;public abstract class GreyMapOp implements Buffered<strong>Image</strong>Op {protected byte[] table = new byte[256];public int getTableEntry(int i) {if (table[i] < 0)return 256 + (int) table[i];elsereturn (int) table[i];}protected void setTableEntry(int i, int value) {if (value < 0)table[i] = (byte) 0;else if (value > 255)table[i] = (byte) 255;elsetable[i] = (byte) value;}public void computeMapping() {}computeMapping(0, 255);- 23 -

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

Saved successfully!

Ooh no, something went wrong!