LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Best way to draw straight line between two points on intensity graph? (LV 7.1)

Hi Folks:

Through another thread on this forum, we developed a nice way to draw on intensity graphs using cursors (using LV 7.1) (see attached).

My question now relates to using this methodology to draw a line between any two points on an intensity graph.  If the two points are not separated by equal pixel distances, a protocol needs to be created that allows the straightest line to be drawn by creating the appropriate array of cursors.  For example, if the position of the two points that a line needs to connect are (x=80, y=102) & (x=97, y = 131), the delta X and delta Y are 17 and 29, respectively.  My initial thought is to do something like the following:

1) divide larger Delta by smaller Delta (egs. from above, 29/17),
2) round up to nearest integer, to obtain a "factor" that one would use to develop the coordinates for the cursor positions (egs. 29/17 --> 2)
3) match the coordinates for x and y according to this factor (egs. cursor0 at x = 81, y = 104; cursor1 at x=82, y=106, etc.)

The problem is that at some point, the line will hit (in this example) the top Y bound prior to using up the entire X array coordinates.

Any suggestions on the best way to accomplish what I am thinking about?

Thanks,

Don
0 Kudos
Message 1 of 16
(6,878 Views)
It seems not very efficient to create a ton of cursors just to draw a line.
 
You have several options.
 
You could just make a unique and contrasting over- or underflow color, then  temporarily replace array elements at the correct indices with a very high or low value.
 
You might want to consider replacing your intensity chart with an image indocator. Now you can draw on top of it. 🙂
 
Much better would be to upgrade to LabVIEW 8.0. Here you can draw anything you want on your existing intensity graph area. Look for the property "plot images:front". 😄
0 Kudos
Message 2 of 16
(6,874 Views)

I think we talked about this before but I need to stay on LV7.1 for this effort.  I know about LV8 new capabilities now and will be playing with them.

 

The cursor creation capability is actually quite robust and quickly done to create the effect.  In fact, there is likely already a numerical recipe somewhere that I will end up recreating to define the best set of points I need to draw the line of cursors (unless someone comes up with something I am not thinking about).

 

I am not sure what you mean by image indicators (unless you are talking about LV8 again?) ---> if you are talking about a picture control, yes I know we can draw lines on a picture control but I need to use the intensity graph for a variety of reasons. If you are talking about Vision Image Controls, again I need to stay with the intensity graph.

 

Sincerely,

 

Don

0 Kudos
Message 3 of 16
(6,860 Views)
ps. I know also about the overflow / underflow method you speak of.  I have a routine that allows me to remove outliers in intensity graphs and recolor them based on whether they are underflow or overflow.  But this routine is based on the grey value of the pixel and not the location.  I have to think about how I could modify based on pixel location, and whether really better than cursor creation method.
0 Kudos
Message 4 of 16
(6,856 Views)


@DonRoth wrote:

Iif you are talking about a picture control, yes I know we can draw lines on a picture control but I need to use the intensity graph for a variety of reasons.


Yes, picture control. I don't think it would be too hard to imitate an intensity graph using a picture control. Have you tried?
0 Kudos
Message 5 of 16
(6,848 Views)
I am actually using a picture control in a different part of the program and have developed with some help a bunch of routines to convert from picture control to intensity graph and back.  In this case, I need use of cursors that the intensity graph has and actually the line to be drawn will connect the centers of the two cursors as they are being moved across the image.....Don
0 Kudos
Message 6 of 16
(6,840 Views)
Have a look at my old example here:
 
 
It temporarily draws a box on a picture.
 
I quickly modified it to draw a line instead (See attached example). It would be easy to add more features such as fake cursors, etc.
0 Kudos
Message 7 of 16
(6,831 Views)
Another possibility is to use a line decoration. See this post:
 
0 Kudos
Message 8 of 16
(6,824 Views)
I've been on travel this week but I had a chance to look at this tonite again.  I have now realized that the cursor positions actually are dbl precision entries, thus I think we can do this pretty easily with the cursor draws I proposed.  My original thinking is that I had to put the cursor draws at discrete locations based on the pixel positions within the image, but this is not so.  I got started and have a temporary solution that works if one makes sure that cursor1 is to the right and above cursor 0.  I'll take care of the other situations and post later but thought you might like to see the interim solution.  And for now, I fixed the number of cursors at 10 but the number can be based on specified criterion and determined programmatically.

I will take a look at the other solutions you propose as well but again, for now, I wanted to stay with the intensity graph for other reasons (which means the picture control solution is probably not good for this situation).

Sincerely,

Don
0 Kudos
Message 9 of 16
(6,802 Views)
OK, try this and let me know what you think.  Move cursors 0 and 1 to any location on the intensity graph and run.  Move again and rerun.  Etc. Etc.

Sincerely,

Don
0 Kudos
Message 10 of 16
(6,794 Views)