Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Update picture control

Hi,
 
I understand that this question has been posted before, but I seem to have a unique situation. 
 
What I am trying to do is take random x-y coordinates (for testing purposes) and plot these points
on a pixel in the picture control with random coloring.  In the end, the result would be a 3-D plot with
the z direction being the color. I would like to update the picture control in almost real-time with the
previous points still visible on the picture.  I noticed that if I stored this data in an array and then used
the shift registers to return the data, that my program would lag.  So, I suppose my question is, how
can you update the picture control without storing an array?  I have tried to disable the erase first
property, but when I run the program, the previous data is not saved on the picture. 
 
Thank you for your help,
 
Kate
0 Kudos
Message 1 of 8
(4,342 Views)

I see two things for you to think about.

If you add one point at a time to an array using build array, it will go slower and slower.  It takes time to allocate more space for the array, and one point at a time is the worst way to do it.  A better way is to allocate a large array at the beginning and replace one point at a time.  This will speed things up quite a bit.

Another is that you can use a shift register to store the picture itself.  Use a blank picture going into the loop, and add each point inside the loop.  You can display the picture after you add each point or at the end.

Bruce

Bruce Ammons
Ammons Engineering
0 Kudos
Message 2 of 8
(4,343 Views)

Bruce is correct in his theory. Every time you add to the array LabVIEW has to create a new memory space for the new array. This will drastically slow down the performance of your program. If you follow his suggestion and Initilze and array of the maxium size you wish, then LabVIEW will only need to interact with that one memory space, greatly improving the performance of the program.

Tyler H.

 

0 Kudos
Message 3 of 8
(4,322 Views)

Thank you for your responses.  Since the array size will vary greatly in size, I think

the best route for me is to store the picture and update with a shift register.  This

is where I am having problems again.  I attached a screen shot of what I have so far.

I have added the shift registers and I have the empy picture wired to the subVI shown. 

The SubVI formats the picture and displays it.  The empty picure from the main VI is linked

to the Draw Unflattened Pixmap function's empty picture sink.  When I run this VI, the picture

updates, but does not keep the previous points on the picture.  Any ideas?

 

Thanks again,

Kate

0 Kudos
Message 4 of 8
(4,307 Views)

Hello,

 

Thank you for posting to the NI discussion forums!  Sorry I am joining this conversation a little late, but I am unclear about exactly what is going on.  What do you mean by “the picture updates, but does not keep the previous points on the picture”?  The picture of your sub-VI doesn’t appear to match the call in your main VI either (for example, what happens to all of those double numbers going to the picture sub VI?).  I think what you want to plot a picture, and update some specified points with random colors.  To do this, first draw the picture like you mention, pass your 2-D array around with a shift register and use the “replace array subset” to change the points you are interested in, and redraw the picture.  The attached VI (for LV8) plots a picture of random pixel colors, and replaces the point you specify with the color you specify.  Hopefully this helps provide you with a good start for programming your application!

Message Edited by Travis M. on 03-29-2006 12:24 PM

Travis M
LabVIEW R&D
National Instruments
0 Kudos
Message 5 of 8
(4,293 Views)
Hi,
 
What I mean by “the picture updates, but does not keep the previous points on the picture” is that
each time data is generated, the correct point is depicted on the picture, but when a new point
is sent to the picture, the previous point is replaced by the new one.  In the end there is only
one point shown when there should be multiple. 
 
Yes, the picture of the subVI does not match the call statement in my main VI.  This is because
I left out the code that generates my picture data.  The code that I left out takes the double constants
on the main Vi and basically creates a box 10 X 10 with 25 elements.  The bottom and side lengths
represent 10 inches, so each pixel/point size represents a box of 2 x 2inches.  Say the position point is
(2.5,6) the x-y coordinate on the picture would show (2,3).  This is done so we have control over the
resolution. Let me know if you would like to see a jpg of this. 
 
I have not tried the "Replace Array Subset" yet.  I will look into this and let you know what I come up with.
 
Also, I am using labview 7.1, so I was unable to open your attachment.  Would you be able to send me a
screen shot?
 
Thank you for your help!
-Kate
0 Kudos
Message 6 of 8
(4,281 Views)
Sure thing,  here's the VI in 7.1 form.

Hope it helps!
Travis M
LabVIEW R&D
National Instruments
0 Kudos
Message 7 of 8
(4,265 Views)
That's exactly what I am looking for! Smiley Happy
 
Thank you so much for your help!!!
 
-Kate
0 Kudos
Message 8 of 8
(4,241 Views)