I at moment trying to save a Mat which is given the type Mat_<float>.. When i try to save it it saver an black image, but imshow shows that the image isn't black at all. Is there a way to save the image even though it has the type Mat_float?
1 | initial version |
I at moment trying to save a Mat which is given the type Mat_<float>.. When i try to save it it saver an black image, but imshow shows that the image isn't black at all. Is there a way to save the image even though it has the type Mat_float?
2 | No.2 Revision |
I at moment trying to save a Mat which is given the type Mat_<float>.. When i try to save it it saver an black image, but imshow shows that the image isn't black at all. Is there a way to save the image even though it has the type Mat_float?
I am not sure whether this is going to help but there is the function where i want to save the image
void fft2(Mat_<float> src)
{
int x = getOptimalDFTSize(2* src.rows );
int y = getOptimalDFTSize(2* src.cols );
copyMakeBorder(src, src, 0, (x - src.rows), 0, (y - src.cols), BORDER_CONSTANT, Scalar::all(0));
// Get padded image size
const int wx = src.cols, wy = src.rows;
const int cx = wx/2, cy = wy/2;
//--------------------------------//
// DFT - performing //
cv::Mat_<float> imgs[] = {src.clone(), Mat::zeros(src.size(), CV_32F)};
cv::Mat_<cv::Vec2f> img_dft;
merge(imgs,2,img_dft);
dft(img_dft, img_dft);
split(img_dft,imgs);
cv::Mat_<float> magnitude, phase;
cartToPolar(imgs[0],imgs[1],magnitude,phase);
dftshift(magnitude);
magnitude = magnitude + 1.0f;
log(magnitude,magnitude);
normalize(magnitude,magnitude,0,1,CV_MINMAX);
namedWindow("img_dft",WINDOW_NORMAL);
imshow("img_dft",magnitude);
//imwrite
waitKey(0);
cout << "out" << endl;
}
Here is the function which is intended to be used for outputting the images.. but the images i save always becomes black..
3 | No.3 Revision |
I at moment trying to save a Mat which is given the type Mat_<float>.. When i try to save it, the image which it it saver an black image, saves becomes black, but imshow shows that the image isn't black at all. Is there a way to save the image even though it has the type Mat_float?
I am not sure whether this is going to help but there is the function where i want to save the image
void fft2(Mat_<float> src)
{
int x = getOptimalDFTSize(2* src.rows );
int y = getOptimalDFTSize(2* src.cols );
copyMakeBorder(src, src, 0, (x - src.rows), 0, (y - src.cols), BORDER_CONSTANT, Scalar::all(0));
// Get padded image size
const int wx = src.cols, wy = src.rows;
const int cx = wx/2, cy = wy/2;
//--------------------------------//
// DFT - performing //
cv::Mat_<float> imgs[] = {src.clone(), Mat::zeros(src.size(), CV_32F)};
cv::Mat_<cv::Vec2f> img_dft;
merge(imgs,2,img_dft);
dft(img_dft, img_dft);
split(img_dft,imgs);
cv::Mat_<float> magnitude, phase;
cartToPolar(imgs[0],imgs[1],magnitude,phase);
dftshift(magnitude);
magnitude = magnitude + 1.0f;
log(magnitude,magnitude);
normalize(magnitude,magnitude,0,1,CV_MINMAX);
namedWindow("img_dft",WINDOW_NORMAL);
imshow("img_dft",magnitude);
//imwrite
waitKey(0);
cout << "out" << endl;
}
Here is the function which is intended to be used for outputting the images.. but the images i save always becomes black..