Quantcast
Channel: OpenCV Q&A Forum - Latest question feed
Viewing all articles
Browse latest Browse all 600

fog removal C++ code

$
0
0
Hello Dear All, I am trying to run this simple fog removal which takes an input RGB image and removes fog from it. When i run the following code, it gives me the following exception. Exception at memory location 0x000000B8FD6FE6A0. I think the possible reasons might be static casting in the transmission map and original image recovery part. Any help would be deeply appreciated. int main(int, char** argv) { Mat input_image; double patchsize = 3; double m_AtmosLight = 255.0; double _t = 255.0; double w = 1; Mat m_DarkChannelImage; Mat m_RecoveredImage; const char* source_window = "Source image"; const char* dark_channel = "Dark Channel"; namedWindow(source_window, WINDOW_AUTOSIZE); imshow(source_window, input_image); input_image.convertTo(input_image, CV_64FC3); // Dark Channel Creation vector planes(3); split(input_image, planes); m_DarkChannelImage=min(planes[2], min(planes[1], planes[0])); namedWindow(dark_channel, WINDOW_AUTOSIZE); imshow(dark_channel, m_DarkChannelImage); // Original Image Recovery part for (int i = 0; i < input_image.rows; i++) { for (int j = 0; j < input_image.cols; j++) { double t = std::max(1 - (w*m_DarkChannelImage.at(i, j) / m_AtmosLight), _t); m_RecoveredImage.at(i, j)[0] = static_cast(std::min(((input_image.at(i, j)[0] - m_AtmosLight) / t + m_AtmosLight), 255.0)); m_RecoveredImage.at(i, j)[1] = static_cast(std::min(((input_image.at(i, j)[1] - m_AtmosLight) / t + m_AtmosLight), 255.0)); m_RecoveredImage.at(i, j)[2] = static_cast(std::min(((input_image.at(i, j)[2] - m_AtmosLight) / t + m_AtmosLight), 255.0)); } } waitKey(0); system("pause"); return 0; }

Viewing all articles
Browse latest Browse all 600

Trending Articles