saving and loading mat histogram [closed]

asked 2014-01-28 21:40:30 -0600

lala gravatar image

updated 2020-11-13 04:04:14 -0600

i already have my histogram, now i want to save the histogram data and call it back to do comparison. But when I try to show the image of "histogram1" and "histogram2" it gives unhandled exception error. here's my code

// save file
Mat result1
Mat result2
cv::FileStorage fs("results_file.yml", cv::FileStorage::WRITE);
fs << "result1" << result1 ;
fs << "result2" << result2 ;
fs.release();

// load file
cv::FileStorage fs("results_file.yml", cv::FileStorage::READ);
Mat histogram1 ;
Mat histogram2 ;
fs["result1"] >> histogram1 ;
fs["result2"] >> histogram2 ;
fs.release();
imshow("histogram1",histogram1);
imshow("histogram2",histogram2);
edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by sturkmen
close date 2020-11-13 04:04:52.550679

Comments

1

what's the exception, exactly ?

besides, a histogram is not an image. you'd have to draw bars or similar to visualize it.

berak gravatar imageberak ( 2014-01-29 05:11:45 -0600 )edit
2

my crystal ball tells me: you're throwing a 2 channel histogram mat at imshow(), which can only handle 1,3 or 4 channel input

berak gravatar imageberak ( 2014-01-29 13:33:18 -0600 )edit

Nice to see you can guess the future @berak!

StevenPuttemans gravatar imageStevenPuttemans ( 2014-01-30 02:42:35 -0600 )edit
1

we'll see about that ;)

berak gravatar imageberak ( 2014-01-30 02:45:45 -0600 )edit