OpenCV的imshow无法正常显示图片

最后更新于:2022-04-01 14:29:46

**问题:**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://docs.gechiui.com/gc-content/uploads/sites/kancloud/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://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-04-07_570617928dfa0.jpg) ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-04-07_57061792ab52b.jpg)
';