// Calculate the wrapped phase
phase_value = atan( sqrt(3.0) * (intensity_phase_n120 - intensity_phase_p120) /
(2.0*(intensity_phase_0)-(intensity_phase_n120)-(intensity_phase_p120)) )
/ THREE_PHASE_PI
if((phase_value >= 0.5) || (phase_value <= -0.5)){
// Pixel is invalid
disparity_value = dlp::DisparityMap::INVALID_PIXEL;
}
else{
// Convert the phase to a wrapped pixel value
disparity_value = lroundf(over_sample*(phase_value + 0.5) * ((float)this->resolution_) / this->phase_counts_);//获取所在的像素点处于第几个二值化条纹周期
if(this->use_hybrid_.Get()){
// Get the gray code disparity pixel value
gray_code_disparity.Unsafe_GetPixel(xCol,yRow,&gray_code_disparity_value);
//disparity_vals[(unsigned int)gray_code_disparity_value]++;
if((gray_code_disparity_value != dlp::DisparityMap::INVALID_PIXEL) &&
(gray_code_disparity_value != dlp::DisparityMap::EMPTY_PIXEL)){
// Check that the phase change regions are correct
if(((gray_code_disparity_value+1) % 4) == 0){
// The fourth region of a period should be greater than
// 0.25 and absolutely greater than 0. If it is less than
// zero the phase has been missclassified
if(phase_value < 0) gray_code_disparity_value++;
}
else if(((gray_code_disparity_value+1) % 4) == 1){
// The first region of a period should be less than
// -0.25 and absolutely less than 0. If it is greater than
// zero the phase has been missclassified
if(phase_value > 0) gray_code_disparity_value--;
}
// Adjust the GrayCode disparity value to the phase regions
gray_code_disparity_value = gray_code_disparity_value / 4;
// Add the GrayCode disparity value to unwrap the values
disparity_value += (over_sample*gray_code_disparity_value*this->resolution_/this->phase_counts_);
}
else{
disparity_value = dlp::DisparityMap::INVALID_PIXEL;
}
}
else{
// Non hybrid method not implemented
disparity_value = dlp::DisparityMap::INVALID_PIXEL;
}
}
// Save the calculated pixel value
this->disparity_map_.Unsafe_SetPixel(xCol,yRow,disparity_value);
}
}