/*
* Copyright (c) 2011-2016, Peter Abeles. All Rights Reserved.
*
* This file is part of BoofCV (http://boofcv.org).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package boofcv.alg.feature.disparity.impl;
import boofcv.alg.feature.disparity.DisparitySparseScoreSadRect;
import boofcv.struct.image.GrayF32;
import java.util.Arrays;
/**
*
* Implementation of {@link DisparitySparseScoreSadRect} that processes images of type {@link GrayF32}.
*
*
*
* DO NOT MODIFY. Generated by {@link GenerateDisparitySparseScoreSadRect}.
*
*
* @author Peter Abeles
*/
public class ImplDisparitySparseScoreSadRect_F32 extends DisparitySparseScoreSadRect {
// scores up to the maximum baseline
float scores[];
public ImplDisparitySparseScoreSadRect_F32( int minDisparity , int maxDisparity, int radiusX, int radiusY) {
super(minDisparity,maxDisparity,radiusX, radiusY);
scores = new float[ maxDisparity ];
}
@Override
public boolean process( int x , int y ) {
// adjust disparity for image border
localMaxDisparity = Math.min(rangeDisparity,x-radiusX+1-minDisparity);
if( localMaxDisparity <= 0 || x >= left.width-radiusX || y < radiusY || y >= left.height-radiusY )
return false;
Arrays.fill(scores,0);
// sum up horizontal errors in the region
for( int row = 0; row < regionHeight; row++ ) {
// pixel indexes
int startLeft = left.startIndex + left.stride*(y-radiusY+row) + x-radiusX;
int startRight = right.startIndex + right.stride*(y-radiusY+row) + x-radiusX-minDisparity;
for( int i = 0; i < localMaxDisparity; i++ ) {
int indexLeft = startLeft;
int indexRight = startRight-i;
float score = 0;
for( int j = 0; j < regionWidth; j++ ) {
float diff = (left.data[ indexLeft++ ]) - (right.data[ indexRight++ ]);
score += Math.abs(diff);
}
scores[i] += score;
}
}
return true;
}
@Override
public float[] getScore() {
return scores;
}
@Override
public Class getImageType() {
return GrayF32.class;
}
}
Ads help maintain this website.