<commit_before>#!/bin/bash

# get real path of the jar file
rel_path_script=`dirname $0`

if [ "$3" == "" ]; then
   echo "Usage:"
   $rel_path_script/SGBM
   echo ""
   echo "   Implements: <NAME>, <NAME>, and J.Garibaldi. "
   echo "   \"Real-Time Correlation-Based Stereo Vision with Reduced Border Errors.\" "
   echo "   Int. J. Comput. Vision 47, 1-3 2002"
   exit 1
fi

a=$1
b=$2


# convert input images to png
aa=$(basename "$a")
a_extension="${aa##*.}"
a_name="${aa%.*}"
bb=$(basename "$b")
b_extension="${bb##*.}"
b_name="${bb%.*}"
if [ $a_extension == "tif" ]; then
    thresholds=`qauto $a /tmp/$a_name.png 2>&1 |  cut -f2 -d=`
    a=/tmp/$a_name.png
    # use the same threshods for the second image
    qeasy $thresholds $b /tmp/$b_name.png
    b=/tmp/$b_name.png

    # HACK! make it invariant to illumination changes?
    gblur 2 $a   | plambda  - " x 4 *    x(-1,0)  -1 *  +  x(1,0)  -1 * +  x(0,-1)  -1 * +    x(0,1)  -1 * + " | qauto - $a
    gblur 2 $b   | plambda  - " x 4 *    x(-1,0)  -1 *  +  x(1,0)  -1 * +  x(0,-1)  -1 * +    x(0,1)  -1 * + " | qauto - $b

fi


$rel_path_script/SGBM $a $b $3 $4 $5 $6 $7 $8 $9
plambda $3 "x isnan 0 255 if" | iion - ${3}.mask.png

rm $a $b<commit_msg>changed interface of stereo_hirschmuller_2008/callSGM.sh to pass the output mask as a parameter<commit_after>#!/bin/bash

# get real path of the binary file
rel_path_script=`dirname $0`

if [ "$3" == "" ]; then
   echo "Usage:"
   echo "  $0 im1 im2 out_disp out_mask [mindisp(0) maxdisp(60) LoG(0) regionRadius(3) maxPerPixelError(20) validateRtoL(1) texture(0.2)]"
   echo ""
   echo "  LoG: Laplacian of Gaussian preprocess 1:enabled 0:disabled"
   echo "  regionRadius: radius of the window"
   echo "  maxPerPixelError: <0 disabled"
   echo "  validateRtoL: 1:enabled 0:disabled"
   echo "  texture: normalized diffrence between best and second best minimum  0:disabled"
   echo ""
   echo "  Wrapper to opencv SGBM function, which implements a modified version"
   echo "  of Hirschmuller's Semi-Global Matching (SGM):"
   echo "  <NAME>. \"Stereo Processing by Semiglobal Matching and Mutual Information\""
   echo "  PAMI(30), No. 2, February 2008, pp. 328-34"
   exit 1
fi

a=$1
b=$2
disp=$3
mask=$4
im=$5
iM=$6

SAD_win=$7
P1=$8
P2=$9
lr=${10}


# convert input images to png
aa=$(basename "$a")
a_extension="${aa##*.}"
a_name="${aa%.*}"
bb=$(basename "$b")
b_extension="${bb##*.}"
b_name="${bb%.*}"
if [ $a_extension == "tif" ]; then
    thresholds=`qauto $a /tmp/$a_name.png 2>&1 |  cut -f2 -d=`
    a=/tmp/$a_name.png
    # use the same threshods for the second image
    qeasy $thresholds $b /tmp/$b_name.png
    b=/tmp/$b_name.png

    # HACK! make it invariant to illumination changes?
    gblur 2 $a   | plambda  - " x 4 *    x(-1,0)  -1 *  +  x(1,0)  -1 * +  x(0,-1)  -1 * +    x(0,1)  -1 * + " | qauto - $a
    gblur 2 $b   | plambda  - " x 4 *    x(-1,0)  -1 *  +  x(1,0)  -1 * +  x(0,-1)  -1 * +    x(0,1)  -1 * + " | qauto - $b

fi

#usage: ./build/SGBM im1 im2 out [mindisp(0) maxdisp(64) SADwindow(1) P1(0) P2(0) LRdiff(1)]
$rel_path_script/SGBM $a $b $disp $im $iM $SAD_win $P1 $P2 $lr
plambda $disp "x isnan 0 255 if" | iion - $mask

rm $a $b
{'fraction_non_alphanumeric': 0.18050314465408804, 'fraction_numerical': 0.04905660377358491, 'mean_word_length': 2.8982843137254903, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2880667', 'n_tokens_mistral': 1426, 'n_tokens_neox': 1320, 'n_words': 377}