Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Fast intensity graph possible ???

I want to display some images (echographic images for information) in a 1st intensity graph, extract a given column and display it in a 2nd intensity graph.

I have already seen that I have to use the 3Dgraphs. But It seems to be "very slow". Every code line as "m_MyGraph3.Plot3DSimpleSurface(MyMatrixData)" takes between 50 and 60 ms !!!

My images size is approximately 300*300 pixels.

I have also a 2nd question concerning the cast that I have to perform on the raw data acquired by our device in order to display it. For 2D graph with vector of data I use the following "single line" declaration code:

"CNiReal64Vector DataNi(vectorsize, RawDataPointer)"

Can I perform same thing for 3D graph/matrix of data ???

Thank you in advance.
0 Kudos
Message 1 of 3
(3,512 Views)
The best way to do this is using the background image of a 2D Scattergraph. Each pixel in the bitmap is a data point. It is really fast. I can do a 3200X1024 bitmap each second without any noticable flicker. Here's some C# code on how to do it.

Note I'm using a gray scale bitmap which is a byte array and a certain PixelFormat. Just use an int array for the bitmap and specify a PixelFormat of color (32bit RGB).

There you have it.

Scott




private void ShowBlockOfData()
{
int width = _EqualizedData[0].Length;
int height = _EqualizedData.Length;
scatterGraph1.PlotAreaImageAlignment = ImageAlignment.Center;

PrepareBitmap(width, height );

//
// Now create a dummy bitmap. Use the LockBits method to lock the data in
// memory. This is much faster than SetPixel (I'm not sure you
// can use SetPixel with an Indexed type image. )

Rectangle rec = new Rectangle(0, 0, _Plot.Width, _Plot.Height);

BitmapData bmd = _Plot.LockBits( rec, System.Drawing.Imaging.ImageLockMode.ReadWrite, _Plot.PixelFormat);

unsafe
{
for(int y=0; y < bmd.Height; y++)
{
byte* row= (byte*)bmd.Scan0.ToPointer()+(y*bmd.Stride);
for(int x=0; x < bmd.Width; x++ )
{
row[x] = _EqualizedData[y][x];
}
}
}

_Plot.UnlockBits(bmd);
scatterGraph1.PlotAreaImage = _Plot;
}

private void PrepareBitmap(int width, int height )
{
// Create a new bitmap the first time, otherwise use the old one
// to create a new one. Hopefully, this will save us resources.
if ( _Plot == null )
_Plot = new Bitmap(width, height, PixelFormat.Format8bppIndexed );

AssignPalette( );
}

///
/// If the palette is null, create it and preserve it internally
/// Set the images palette to our ColorPalette member.
///

private void AssignPalette()
{
if ( _palette == null )
{
// Get the color palette from the image. You can't
// create one from scratch.
_palette = _Plot.Palette;
// Create a grayscale palette by changing this one.
for ( int i = 0; i < _palette.Entries.Length; i++ )
{
int c = 255-i;
_palette.Entries[i] = Color.FromArgb( c,c,c );
}
}

_Plot.Palette = _palette;
}
Message 2 of 3
(3,502 Views)
Thank you for your response

I have not tested your code now, but I not really understand it. Is ScatterGraph1 a CNI2DGraph in your example ? In that case I don't know function such as PlotAreaImageAlignment ...

Have you complete project example in order to test it ?

I have also tested another "older" example from you (called "SampleMDI with Dynamic Data") but I can not open it (not any .dsw project file).

Thanks a lot

Fabrice
0 Kudos
Message 3 of 3
(3,479 Views)