ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
**问题:**OpenCV的imshow无法正常显示图片 **解决方法:**在imshow()语句下一句添加waitKey(30)  ~~~ int main() { inputImg = imread("input.bmp"); imshow("input image", inputImg);//显示原图 //waitKey(30); imgSplit(inputImg);//求取M(x) imgBlur(mImg);//均值滤波 imgAvg(mImg);//求M(x)中所有元素均值 imgL(blurImg, mImg);//求L(x) imgMaxInput(inputImg);//求maxImg A = imgA(imgMaxpx(blurImg), imgMaxpx(maxImg));//求A imgDefogged(inputImg);//去雾 imshow("defoggedImg", defoggedImg);//显示去雾后的图 imwrite("defoggedImg.bmp", defoggedImg); //waitKey(0); system("pause"); return 0; } ~~~ ![](https://box.kancloud.cn/2016-04-07_5706179276895.jpg) ~~~ #include<opencv2/opencv.hpp> #include<opencv2/core/core.hpp> #include<opencv2/imgproc/imgproc.hpp> #include<opencv2/highgui/highgui.hpp> #include<opencv/cv.h> using namespace std; using namespace cv; int main() { inputImg = imread("input.bmp"); imshow("input image", inputImg);//显示原图 waitKey(30); imgSplit(inputImg);//求取M(x) imgBlur(mImg);//均值滤波 imgAvg(mImg);//求M(x)中所有元素均值 imgL(blurImg, mImg);//求L(x) imgMaxInput(inputImg);//求maxImg A = imgA(imgMaxpx(blurImg), imgMaxpx(maxImg));//求A imgDefogged(inputImg);//去雾 imshow("defoggedImg", defoggedImg);//显示去雾后的图 imwrite("defoggedImg.bmp", defoggedImg); waitKey(0); system("pause"); return 0; } ~~~ ![](https://box.kancloud.cn/2016-04-07_570617928dfa0.jpg) ![](https://box.kancloud.cn/2016-04-07_57061792ab52b.jpg)