Revision 43864 branches/org.gvsig.desktop-2018a/org.gvsig.desktop.library/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.buffer.impl/src/main/java/org/gvsig/raster/lib/buffer/impl/operations/edgedetection/firstderivative/FirstDerivativeOperation.java

View differences:

FirstDerivativeOperation.java
89 89
     *
90 90
     */
91 91
    public FirstDerivativeOperation(OperationFactory factory) {
92
        this.factory = factory;
92
        super(factory);
93 93
    }
94 94

  
95 95
    @Override
......
97 97
        super.preProcess();
98 98
        BufferManager manager = BufferLocator.getBufferManager();
99 99

  
100
        if(this.parameters.getDynClass().getDynField(OPERATOR_PARAM)!=null) {
101
            operator = (String)this.parameters.getDynValue(OPERATOR_PARAM);
102
        } else {
103
            operator = SOBEL_OPERATOR_STRING;
104
        };
105

  
100
        operator = (String) this.getParameter(OPERATOR_PARAM, SOBEL_OPERATOR_STRING);
101
        
106 102
        switch (operator) {
107 103
        case SOBEL_OPERATOR_STRING:
108 104
            operatorH = manager.createKernel(sobelH);
......
122 118
            break;
123 119
        }
124 120

  
125
        if(this.parameters.getDynClass().getDynField(COMPARE_PARAM)!=null) {
126
            compare = (Boolean)this.parameters.getDynValue(COMPARE_PARAM);
127
        } else {
128
            compare = false;
129
        };
130
        if(this.parameters.getDynClass().getDynField(UMBRAL_PARAM)!=null) {
131
            umbral = (Integer)this.parameters.getDynValue(UMBRAL_PARAM);
132
        } else {
133
            umbral = 0;
134
        };
121
        compare = (boolean) this.getParameter(COMPARE_PARAM, false);
122
        umbral = (int) this.getParameter(UMBRAL_PARAM, 0);
135 123

  
136
        int bands = this.buffer.getBandCount();
137
        NoData[] noData = this.buffer.getBandNoData();
138
        if (copyUnprocessedBands) {
124
        int bands = this.getInputBuffer().getBandCount();
125
        NoData[] noData = this.getInputBuffer().getBandNoData();
126
        if (mustCopyUnprocessedBands()) {
139 127
            try {
140
                this.outputBuffer =
141
                    manager.createBuffer(this.buffer.getRows(), this.buffer.getColumns(), this.buffer.getBandTypes(),
142
                        this.buffer.getBandNoData(), this.buffer.getProjection(), this.buffer.getEnvelope());
128
                this.setOutputBuffer(
129
                    manager.createBuffer(
130
                            this.getInputBuffer().getRows(), 
131
                            this.getInputBuffer().getColumns(), 
132
                            this.getInputBuffer().getBandTypes(),
133
                            this.getInputBuffer().getBandNoData(), 
134
                            this.getInputBuffer().getProjection(), 
135
                            this.getInputBuffer().getEnvelope()));
143 136
            } catch (LocatorException | BufferException | CreateEnvelopeException e) {
144 137
                throw new ProcessingOperationException(e);
145 138
            }
146 139
        } else {
147
            List<NoData> noDatas = new ArrayList<NoData>();
148
            List<Integer> types = new ArrayList<Integer>();
149
            for (int band = 0; band < bands; band++) {
150
                if (isProcessableBand(band)) {
151
                    if(this.buffer.getBandNoData()[band].isDefined()){
152
                        noDatas.add(manager.createNoData(0, 0));
153
                    } else {
154
                        noDatas.add(null);
155
                    }
156
                    types.add(BufferManager.TYPE_BYTE);
157
                }
158
            }
159
            int[] typesInt = new int[types.size()];
160
            for (Iterator<Integer> iterator = types.iterator(); iterator.hasNext();) {
161
                int i = 0;
162
                Integer type = (Integer) iterator.next();
163
                typesInt[i] = type.intValue();
164
            }
165 140
            try {
166
                this.outputBuffer =
167
                    manager.createBuffer(this.buffer.getRows(), this.buffer.getColumns(), typesInt,
168
                        noDatas.toArray(new NoData[0]), this.buffer.getProjection(), this.buffer.getEnvelope());
141
                this.setOutputBuffer(
142
                    manager.createBuffer(
143
                            this.getInputBuffer().getRows(), 
144
                            this.getInputBuffer().getColumns(), 
145
                            this.getProcessableBandTypesAsArray(),
146
                            this.getProcessableBandNoDatasAsArray(), 
147
                            this.getInputBuffer().getProjection(), 
148
                            this.getInputBuffer().getEnvelope()));
169 149
            } catch (LocatorException | BufferException | CreateEnvelopeException e) {
170 150
                throw new ProcessingOperationException(e);
171 151
            }
......
174 154
        rowProcessors = new RowProcessor[bands];
175 155
        for (int band = 0; band < noData.length; band++) {
176 156
            if (isProcessableBand(band)) {
177
                int bandType = this.buffer.getBand(band).getDataType();
157
                int bandType = this.getInputBuffer().getBand(band).getDataType();
178 158
                switch (bandType) {
179 159
                case BufferManager.TYPE_BYTE:
180 160
                    rowProcessors[band] = new ByteRowProcessor(band);
......
204 184
    @Override
205 185
    public void process() throws ProcessingOperationException {
206 186
        super.process();
207
        for (int band=0; band<this.buffer.getBandCount(); band++){
208
            if (bandsToProcess.contains(band)) {
209
                Band bufferBand = this.buffer.getBand(band);
210
                Band outputBufferBand = this.outputBuffer.getBand(band);
187
        for (int band=0; band<this.getInputBuffer().getBandCount(); band++){
188
            if (getBandsToProcess().contains(band)) {
189
                Band bufferBand = this.getInputBuffer().getBand(band);
190
                Band outputBufferBand = this.getOutputBuffer().getBand(band);
211 191

  
212
                for (int row = 0; row < this.buffer.getRows(); row++) {
192
                for (int row = 0; row < this.getInputBuffer().getRows(); row++) {
213 193
                    Object rowBuffer = bufferBand.createRowBuffer();
214 194
                    bufferBand.fetchRow(row, rowBuffer);
215
                    List<Object> bundle = new ArrayList<Object>();
195
                    List<Object> bundle = new ArrayList<>();
216 196
                    //FIXME: Solo se procesan aquellas filas en las que se pueden crear kernels, el resto ?qu? hacer? (ver abajo)
217
                    if ((row - HALF_SIDE_WINDOW >= 0) && (row + HALF_SIDE_WINDOW < this.buffer.getRows())) {
197
                    if ((row - HALF_SIDE_WINDOW >= 0) && (row + HALF_SIDE_WINDOW < this.getInputBuffer().getRows())) {
218 198
                        for (int r = Math.max(row - HALF_SIDE_WINDOW, 0); r <= Math.min(row + HALF_SIDE_WINDOW,
219
                            this.buffer.getRows()-1); r++) {
199
                            this.getInputBuffer().getRows()-1); r++) {
220 200
                            Object bundleRow = bufferBand.createRowBuffer();
221 201
                            bufferBand.fetchRow(r, bundleRow);
222 202
                            bundle.add(bundleRow);
......
230 210
                        outputBufferBand.putRow(row, outputRowBuffer);
231 211
                    } else {
232 212
                        // FIXME: Si son de tipo BYTE, las copio, si no, no hacemos nada
233
                        if(this.buffer.getBandTypes()[band]==BufferManager.TYPE_BYTE){
213
                        if(this.getInputBuffer().getBandTypes()[band]==BufferManager.TYPE_BYTE){
234 214
                            outputBufferBand.putRow(row, rowBuffer);
235 215
                        }
236 216
                    }
237 217
                }
238 218
            } else {
239
                if(copyUnprocessedBands){
219
                if(mustCopyUnprocessedBands()){
240 220
                    try {
241
                        this.outputBuffer.getBand(band).copyFrom(this.buffer.getBand(band));
221
                        this.getOutputBuffer().getBand(band).copyFrom(this.getInputBuffer().getBand(band));
242 222
                    } catch (BandException e) {
243 223
                        throw new ProcessingOperationException(e);
244 224
                    }
......
263 243

  
264 244
        public AbstractRowProcessor(int band) {
265 245
            this.band = band;
266
            noData = buffer.getBand(band).getNoData();
246
            noData = getInputBuffer().getBand(band).getNoData();
267 247
        }
268 248

  
269 249
        @Override

Also available in: Unified diff