how to use imshow in class member?
The following code is used in a class member. Image watch shows the correct picture, but imshow() only gives a gray picture. Am I making mistakes? Thanks a lot.
void plane::Display()
{
using namespace cv;
Mat M(nPixel, nPixel, CV_8UC1);
double MAX = 0;
for (int i = 0; i < nPixel; i++)
{
for (int j = 0; j < nPixel; j++)
{
if (abs((*data)(i, j))>MAX)
MAX = pow(abs((*data)(i, j)), 2);
}
}
for (int i = 0; i < nPixel; i++)
{
for (int j = 0; j < nPixel; j++)
{
M.at<uchar>(i, j) = pow(abs((*data)(i, j)), 2) / MAX * 255;
}
}
namedWindow("Intensity", WINDOW_AUTOSIZE);
imshow("Intensity", M);
}
imshow() does not update unless you call waitKey()
Thanks a lot.
Do you want color?