LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Labview 7.0: how to draw quickly 300,000 points

I need to draw up to 300,000 points in a picture. I do this inside one for loop (see attach) updating the picure every time but this is very time consuming. I would like to complete the drawing in about 1 minute. Any suggestion? Thanks
0 Kudos
Message 1 of 9
(4,395 Views)
Hi,

a fast way to improve the creation of the picture is to move the "Picture Out" control outside the for loop.

With that the picture will be drawn after the loop is complete.

Another way could be, to build a 2D array of "raw" data (cluster of RGB values?) the size the final picture will have and then to change just the elements you want to be changed and then transform this data to a picture. I've never worked wit h picture things in LV but there're quite a few VIs available.

I had a look into "Draw Point.vi" and the operations are quite complicated. So working with "normal" array functions should be much faster.
0 Kudos
Message 2 of 9
(4,395 Views)
Hi,

There is room for some optimalisations...

First, always wire the input of a shift register (unless you're making a
buffer)! The qway it is now, the picture is drawn over the previous data, so
the picture has 2X30000 points after the second run, and 300000 after the
tenth run.

Second, don't update the picture inside the for loop, but after it. The
updating of the control is slow (compared to not updating it...).

Third, remove the pen configuration from "draw point.vi". This only works
when all points can have the same color. If not, update the pen only if the
pen changes.

Fourth (not in attachment), check if a point is visible before drawing it.
Use vi.lib/Picture/PictureSupport.llb VI's to do this (PointInRect.vi is
recommened).

See attachm
ent...

Regards,

Wiebe.

"Pier Giuseppe" wrote in message
news:50650000000800000055BB0000-1073519706000@exchange.ni.com...
> I need to draw up to 300,000 points in a picture. I do this inside one
> for loop (see attach) updating the picure every time but this is very
> time consuming. I would like to complete the drawing in about 1
> minute. Any suggestion? Thanks



[Attachment d_points2.vi, see below]


[Attachment Draw Point Mod.vi, see below]
Download All
0 Kudos
Message 3 of 9
(4,395 Views)
Thanks for your support.
Anyway I think some of the suggestions are not applicable, let me explain:
I can not move picture_out outside the for loop because Draw Point accepts one cluster of two elements (x&y) and not one array (like Draw Multiple Lines). For the same reason building arrays of "raw data" does not solve the problem.
Initialising the shift register does not speed up the process (as far as I see) and I must update the picture every iteration for the above mentioned reason. In my real application I have to update the pen at every iteration because colour and pixel size change and all the points are visible.
Your suggestions are welcome
0 Kudos
Message 4 of 9
(4,395 Views)
Yes, you can move "picture_out" outside the for loop.

See the attached file. As the picture isn't repainted every time a point is added, it's faster a bit...
0 Kudos
Message 5 of 9
(4,395 Views)
You are right: I did not see the attach. The vi is working much better now. Thank you
0 Kudos
Message 6 of 9
(4,395 Views)
Hi,

The shift register does need to be initialised. To prove this, just run the
VI continouselly. Open the tast manager, and see the memory running up. It
isn't slow the first time, but will get slower and slower, until the memory
is swapped to disk, and finally memory shortage messages popup, and the pc
crashes. It might take days, or weeks, but it will happen. It's a memory
leak.

When you say the picture has to be updated every iteration, do you mean you
want to see one dot drawn every iteration (or 30000)?

I can't see why you cannot move the picture indicator outside the loop,
because Draw Point accept one cluster. This has nothing to do with each
other, or perhaps I misunderstand the problem....

From what you're saying, I get the feeling you want to add a sample every
iteration, and draw this with all the old samples. If so, you may be better
of by disselecting the 'clear before drawing' property, and drawing only one
point each iteration. You can still keep an internal record or the
positions... I'll see if I can make an example...

Anyway, using raw data (of one element) will speed up things, but only a
bit. The Draw Point VI doesn't do much, but pasting a few bytes together.

Regards,

Wiebe.

"Pier Giuseppe" wrote in message
news:506500000005000000C2510100-1073519706000@exchange.ni.com...
> Thanks for your support.
> Anyway I think some of the suggestions are not applicable, let me
> explain:
> I can not move picture_out outside the for loop because Draw Point
> accepts one cluster of two elements (x&y) and not one array (like Draw
> Multiple Lines). For the same reason building arrays of "raw data"
> does not solve the problem.
> Initialising the shift register does not speed up the process (as far
> as I see) and I must update the picture every iteration for the above
> mentioned reason. In my real application I have to update the pen at
> every iteration because colour and pixel size change and all the
> points are visible.
> Your suggestions are welcome
0 Kudos
Message 7 of 9
(4,395 Views)
Hi,

Here are some examples.

The first draws only one point every iteration. Because erase first is off,
old points are still shown. However, LV doesn't draw all points! If you look
carefully, some points are missing. This is because LV draws the points only
when updating the screen, if two points are drawn in one screen refresh,
only the last shows.

The second draws every point, because I used a the value property node.
Normally this is undisireable, but in this case it does exactly what is
needed. Howevery, it slows down the for loop to the screen refresh rate...

The first is fast, but inaccurate, the second slower (140sec) and accurate.
Both speeds are constant however, so the number of points drawn shouldn't
mather. Be aware, that if you ever want to use the scroll bars, these
methods cannot be used (moving will clear the picture)!

Experiment with "Synchronous Display", "Smooth Updates" and "Erase First".
They make big differnce!

There are some more options (just ideas, they might or might not work):
1) make a 2d array, and draw figures in it. Then convert the bitmap to
picture and draw the bitmap. It's slow, but the speed will be constant. The
size you can use is limited (by conversion speed)
2) draw small picture arrays (100 points), and once in a while copy it to a
background (second) picture. Make the foreground picture transparent. The
drawing of the second picture must be done in a parrallel loop....





"Wiebe@CARYA" wrote in message
news:401781e1$1@newsgroups....
> Hi,
>
> The shift register does need to be initialised. To prove this, just run
the
> VI continouselly. Open the tast manager, and see the memory running up. It
> isn't slow the first time, but will get slower and slower, until the
memory
> is swapped to disk, and finally memory shortage messages popup, and the pc
> crashes. It might take days, or weeks, but it will happen. It's a memory
> leak.
>
> When you say the picture has to be updated every iteration, do you mean
you
> want to see one dot drawn every iteration (or 30000)?
>
> I can't see why you cannot move the picture indicator outside the loop,
> because Draw Point accept one cluster. This has nothing to do with each
> other, or perhaps I misunderstand the problem....
>
> From what you're saying, I get the feeling you want to add a sample every
> iteration, and draw this with all the old samples. If so, you may be
better
> of by disselecting the 'clear before drawing' property, and drawing only
one
> point each iteration. You can still keep an internal record or the
> positions... I'll see if I can make an example...
>
> Anyway, using raw data (of one element) will speed up things, but only a
> bit. The Draw Point VI doesn't do much, but pasting a few bytes together.
>
> Regards,
>
> Wiebe.
>
> "Pier Giuseppe" wrote in message
> news:506500000005000000C2510100-1073519706000@exchange.ni.com...
> > Thanks for your support.
> > Anyway I think some of the suggestions are not applicable, let me
> > explain:
> > I can not move picture_out outside the for loop because Draw Point
> > accepts one cluster of two elements (x&y) and not one array (like Draw
> > Multiple Lines). For the same reason building arrays of "raw data"
> > does not solve the problem.
> > Initialising the shift register does not speed up the process (as far
> > as I see) and I must update the picture every iteration for the above
> > mentioned reason. In my real application I have to update the pen at
> > every iteration because colour and pixel size change and all the
> > points are visible.
> > Your suggestions are welcome
>
>



[Attachment d_points3.vi, see below]


[Attachment d_points4.vi, see below]
Download All
0 Kudos
Message 8 of 9
(4,395 Views)
Thank you for the examples. You are right about shift register and connecting picture_out outside the loop. My vi is working very well now. Thank you again for your support
0 Kudos
Message 9 of 9
(4,395 Views)