boofcv.alg.feature.disparity.impl.ImplSelectSparseStandardWta_F32 Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of boofcv-feature Show documentation
Show all versions of boofcv-feature Show documentation
BoofCV is an open source Java library for real-time computer vision and robotics applications.
/*
* Copyright (c) 2011-2017, 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.SelectSparseStandardWta;
/**
*
* Implementation of {@link SelectSparseStandardWta} for score arrays of type F32.
*
*
*
* DO NOT MODIFY. Generated by {@link GenerateSelectSparseStandardWta}.
*
*
* @author Peter Abeles
*/
public class ImplSelectSparseStandardWta_F32 extends SelectSparseStandardWta {
// texture threshold
protected float textureThreshold;
public ImplSelectSparseStandardWta_F32(int maxError, double texture) {
super(maxError,texture);
}
@Override
protected void setTexture( double texture ) {
this.textureThreshold = (float)texture;
}
@Override
public boolean select(float[] scores, int maxDisparity) {
int disparity = 0;
float best = scores[0];
for( int i = 1; i < maxDisparity; i++ ) {
if( scores[i] < best ) {
best = scores[i];
disparity = i;
}
}
if( best > maxError ) {
return false;
} else if( textureThreshold > 0 ) {
// find the second best disparity value and exclude its neighbors
float secondBest = Float.MAX_VALUE;
for( int i = 0; i < disparity-1; i++ ) {
if( scores[i] < secondBest )
secondBest = scores[i];
}
for( int i = disparity+2; i < maxDisparity; i++ ) {
if( scores[i] < secondBest )
secondBest = scores[i];
}
// similar scores indicate lack of texture
// C = (C2-C1)/C1
if( secondBest-best <= textureThreshold*best )
return false;
}
this.disparity = disparity;
return true;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy