A disparity value deriving device comprising: a cost calculator configured to calculate, for a reference pixel serving as a reference in a reference image including an image of an object captured by a first imaging unit, a cost indicating dissimilarity between a luminance value of the reference pixel and a luminance value of a comparison pixel to be compared in a comparison image including an image of the object captured by a second imaging unit, for each pixel on an Epipolar line for the comparison pixel that corresponds to an Epipolar line (El) for the reference pixel; a detector configured to detect an edge pixel indicating an edge in the reference image; a path cost calculator configured to calculate a path cost for the reference pixel for each path from a pixel neighboring the reference pixel to the reference pixel, using the cost for the reference pixel calculated by the cost calculator and the path costs for the neighboring pixels; a synthesized cost calculator configured to calculate a synthesized cost for the reference pixel by summing up all the path costs for the reference pixel; and a deriving unit configured to derive a disparity value for the object from a difference in position between the reference pixel in the reference image and a pixel in the comparison image, the pixel corresponding to the smallest synthesized cost for the reference pixel, characterized in that when the reference pixel is an edge pixel, the path cost calculator is configured to change the method of calculating the path cost for the reference pixel , wherein the path cost calculator is configured to set the path cost to the cost for the reference pixel when the reference pixel is an edge pixel. a cost calculator configured to calculate, for a reference pixel serving as a reference in a reference image including an image of an object captured by a first imaging unit, a cost indicating dissimilarity between a luminance value of the reference pixel and a luminance value of a comparison pixel to be compared in a comparison image including an image of the object captured by a second imaging unit, for each pixel on an Epipolar line for the comparison pixel that corresponds to an Epipolar line (El) for the reference pixel; a detector configured to detect an edge pixel indicating an edge in the reference image; a path cost calculator configured to calculate a path cost for the reference pixel for each path from a pixel neighboring the reference pixel to the reference pixel, using the cost for the reference pixel calculated by the cost calculator and the path costs for the neighboring pixels; a synthesized cost calculator configured to calculate a synthesized cost for the reference pixel by summing up all the path costs for the reference pixel; and a deriving unit configured to derive a disparity value for the object from a difference in position between the reference pixel in the reference image and a pixel in the comparison image, the pixel corresponding to the smallest synthesized cost for the reference pixel, characterized in that when the reference pixel is an edge pixel, the path cost calculator is configured to change the method of calculating the path cost for the reference pixel , wherein the path cost calculator is configured to set the path cost to the cost for the reference pixel when the reference pixel is an edge pixel. <EOS>