Ask Your Question

Runtime Error in imshow using the DFT example in Opencv 4.0

asked 2018-12-06 12:31:25 -0500

ikarus23 gravatar image

updated 2018-12-06 12:46:20 -0500

berak gravatar image


I am trying to get the following example for a Fourier transformation running:

I am using the attached input Image: C:\fakepath\lenna.jpg

To read the image directly, i adapted the codeline:

Mat I = imread(filename, IMREAD_GRAYSCALE);


Mat I = imread("lenna.jpg", IMREAD_GRAYSCALE);

Compiling the example works fine. But when i run the Code i get a runtime error when displaying the DFT.

Any ideas whats causing the error?

Setup: Windows 10 with Visual Studio 2017 and OpenCV 4.0.0

Thank you in advance!

edit retag flag offensive close merge delete


when displaying the DFT.

please show the code for that (the code you show so far is unrelated)

berak gravatar imageberak ( 2018-12-06 12:33:34 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2018-12-06 12:38:46 -0500

berak gravatar image

it's probably the bug from here

you want to update your opencv repo to latest master, so you have the proper fix (& rebuild)

in the meantime: convert your image locally to CV_8U:

img.convertTo(img, CV_8U, 255);
imshow("XXX", img);
edit flag offensive delete link more



thank you very much! its working now :)

ikarus23 gravatar imageikarus23 ( 2018-12-06 12:45:03 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2018-12-06 12:31:25 -0500

Seen: 89 times

Last updated: Dec 06 '18