Converting 8bit image into RGB and more

asked 2015-06-30 13:38:55 -0600

pavanbabut gravatar image

Hello all,

I am planning to grab real time images from a scientific framegrabber which is 8bit image data.

The workflow goes as follows- 8bit image data --> convert to RGB image based on predefined color pallete --> (draw some square unfilled boxes) --> (draw some lines on it) --> (update color of some pixels based on other criteria) --> Display it on screen

Steps in () are optional based on user flags. Currently in VC++ 6.0, I do all of these using a mix of GDI+ and SetPixel etc, except for second step. This time I am reqriting the whole applciation in VC++ 2010 and I have OpenCV libraries that I compiled and used in other applciations. Wondering whether this could be accomplished more efficiently in OpenCV, if so, any tips/suggestions?

thanks

edit retag flag offensive close merge delete

Comments

1

I don't know if it's more efficiency than your program but it is a possibilty to do it

m=imread("basketball1.png",CV_LOAD_IMAGE_GRAYSCALE);
vector<uchar> lutr(256),lutg(256),lutb(256);
for (int i = 0; i<lutr.size();i++)
    lutr[i] = i;
for (int i = 0; i<lutg.size();i++)
    lutg[i] = 255-i;
for (int i = 0; i<lutb.size();i++)
    lutb[i] = i/3;
Mat dst;
vector <Mat> plan(3);

LUT(m,lutb,  plan[0]);
LUT(m,lutg,   plan[1]);
LUT(m,lutr,   plan[2]);
    merge(plan,dst);
imwrite("lut.tif",dst);
LBerger gravatar imageLBerger ( 2015-06-30 15:00:54 -0600 )edit

Thanks for your quick reply, I will give this a try in my test program and see how it performs vs GDI+. How about the other graphics drawing stuff, is it easy and efficient to do in OpenCV vs GDI+. I would like to do everything in memory and then draw it on the screen probably utilizing double buffering to reduce flicker.

pavanbabut gravatar imagepavanbabut ( 2015-06-30 17:07:36 -0600 )edit

OpenCV is used for image processing blur, filter threshold, motion detection , stereovision.... using processor or GPU. You can do some basic drawing but it's not principal purpose. OpenGL or VTK can be used inside OpenCV

LBerger gravatar imageLBerger ( 2015-07-01 01:34:40 -0600 )edit