Revision 9523 branches/piloto3d/libraries/libCq CMS for java.old/src/org/cresques/filter/enhancement/LinearEnhancementShortFilter.java

View differences:

LinearEnhancementShortFilter.java
23 23
 */
24 24
package org.cresques.filter.enhancement;
25 25

  
26
import org.cresques.filter.RasterBuf;
26
import java.awt.image.BufferedImage;
27

  
28
import org.cresques.io.data.RasterBuf;
27 29
import org.cresques.io.datastruct.Statistic;
28 30

  
29 31

  
......
33 35
 * @author Nacho Brodin (brodin_ign@gva.es)
34 36
 */
35 37
public class LinearEnhancementShortFilter extends LinearEnhancementFilter {
38
	private short[] 		px = new short[4];
39
	private int 			bandsCnt = 3;
40
	
36 41
    /**
37 42
     * Constructor
38 43
     */
......
54 59
        super.pre();
55 60
    }
56 61

  
57
    /* (non-Javadoc)
58
     * @see org.cresques.io.raster.IRasterFilter#process(int, int)
62
    /**
63
     * Calculo del realce
64
     * @param pt pixel
65
     * @return pixel con el calculo de realce aplicado
59 66
     */
60
    public void process(int x, int y) {
61
        raster.getElemInt(x, y, px);
62

  
63
        int bandsCnt = 3; // Esto hay que sacarlo de fuera, l?gicamente.
64

  
65
        for (int i = 0; i < bandsCnt; i++) {
67
    private short[] calcLinearEnhancement(short[] px){
68
    	for (int i = 0; i < bandsCnt; i++) {
66 69
            if (px[i] > maxBandValue[i]) {
67
                px[i] = maxBandValue[i];
70
                px[i] = (short)maxBandValue[i];
68 71
            } else if (px[i] < minBandValue[i]) {
69
                px[i] = minBandValue[i];
72
                px[i] = (short)minBandValue[i];
70 73
            }
71 74

  
72
            px[i] = (((int) ((((double) px[i]) * scale[i]) + offset[i])) &
73
                    0xff);
75
            px[i] = (short)(((short) ((((double) px[i]) * scale[i]) + offset[i])) & 0xff);
74 76
        }
77
    	return px;
78
    }
75 79

  
76
        raster.setElemInt(x, y, px);
80
    /* (non-Javadoc)
81
     * @see org.cresques.io.raster.IRasterFilter#process(int, int)
82
     */
83
    public void process(int col, int line) {
84
        raster.getElemShort(line, col, px);
85
        px = calcLinearEnhancement(px);
86
        raster.setElemShort(line, col, px);
77 87
    }
78 88

  
79 89
    /* (non-Javadoc)
90
     * @see org.cresques.io.raster.IRasterFilter#processSuperSampling(int, int)
91
     */
92
    public void processSuperSampling(int col, int line) {
93
    	raster.getElemShort(line, col, px);
94
        px = calcLinearEnhancement(px);
95
		for(int j = col; j < raster.getWidth() && j < (col + stepX[contX + 1]); j++)
96
			for(int i = line; i < raster.getHeight() && i < (line + stepY[contY + 1]); i++)
97
				 raster.setElemShort(i, j, px);
98
	}
99
    
100
    /* (non-Javadoc)
80 101
     * @see org.cresques.io.raster.IRasterFilter#getResult(java.lang.String)
81 102
     */
82 103
    public Object getResult(String name) {

Also available in: Unified diff