1. A method for correcting errors in a depth map generated by a structured light system, the method comprising: receiving a plurality of valid codewords and at least one invalid codeword, each of the plurality of valid codewords included in a codebook of valid codewords, the codebook not including the at least one invalid codeword, each codeword representing at least one row and at least one column of pixels of a structured light image, and each codeword corresponding to a location in a depth map; detecting the invalid codeword; retrieving, from a memory unit, a set of candidate codewords that are included in the codebook, each candidate codeword a first Hamming distance from the invalid codeword, the first Hamming distance being a lowest Hamming distance between the at least one invalid codeword and the codewords in the codebook; determining a depth estimate for a plurality of locations of the depth map that include at least one location adjacent to the invalid codeword location in the depth map; associating a depth with each of the candidate codewords; selecting the candidate codeword having an associated depth closest to the determined depth estimate; and assigning the depth associated with the selected candidate codeword to the location of the invalid codeword.