10-22-2026 08:41 AM - edited 10-22-2026 08:49 AM
Hello, this is my first time on labview and i have to make a program where i can draw a rectangle over an image which i choose from my files with a file dialog and save the x1,y1,x2 and y2 coordinates.
I did this code but it has two drawback first the screen flash when you move the mouse because the image get reprinted everytime, and also for some reason the picture control is 1600x900 but when i draw on it, it is 1672x936 and so my rectangle is drawn for the 1600x900 size so it's smaller then how it should compared to the image which get printed at 1672x936.
Also the rectangle is made to be drawn with dash but when i run it, it draw a solid line.
Thanks very much for any response and sorry for my terrible english
Solved! Go to Solution.
10-22-2026 09:06 AM
Hello,
To avoid the flash, you can uncheck the "Erase first" property of the "image carte" indicator on the Front Panel :
For the position and size problem, be careful not to mix : position on monitor, position on front panel, position on indicator.
These are three different things that can lead to headaches if you try to fight them blindly.
10-22-2026 10:41 AM - edited 10-22-2026 10:49 AM
The code you are showing is highly flawed. Why is there a sequence? Where is the top-level loop? (I hope you are not using "continuous run" mode! 😮 )
To draw on a picture indicator with the mouse, you can use an event structure and get the image coordinates.
To get you started, look at my 20+(!!) year old example here. It would be easy to modify for your requirements.
Feel free to attach your code so we give more specific advice. Also make sure to enable "smooth updates" in the picture display. If the picture is too big for the display, you can modify the zoom factor and adjust accordingly.
On a related note, please vote for my idea here!
10-22-2026 07:03 PM
@altenbach wrote:
The code you are showing is highly flawed. Why is there a sequence? Where is the top-level loop? (I hope you are not using "continuous run" mode! 😮 )
To draw on a picture indicator with the mouse, you can use an event structure and get the image coordinates.
To get you started, look at my 20+(!!) year old example here. It would be easy to modify for your requirements.
Feel free to attach your code so we give more specific advice. Also make sure to enable "smooth updates" in the picture display. If the picture is too big for the display, you can modify the zoom factor and adjust accordingly.
On a related note, please vote for my idea here!
Nice.
Here's a sub VI based on that.
10-23-2026 01:52 AM - edited 10-23-2026 01:52 AM
Thanks for everyone answer, i didn't tought anyone would answer
i'll link my .vi so you can understand more how it works but it's very unfinished and bad, i fixed the blinking, tho the coordinates are still not perfect
I will have to divide it into multiple sub-vi i think for my main program, maybe i will try the ImageSubset.vi example but mine kinda work for what i need and imagesubset is confusing me so much.
10-23-2026 09:25 AM
@Timfromcofidur wrote:
Thanks for everyone answer, i didn't tought anyone would answer
i'll link my .vi so you can understand more how it works but it's very unfinished and bad, i fixed the blinking, tho the coordinates are still not perfect
I will have to divide it into multiple sub-vi i think for my main program, maybe i will try the ImageSubset.vi example but mine kinda work for what i need and imagesubset is confusing me so much.
Yikes! That's not serviceable. I suggest that you learn good coding practices, then start over.
10-26-2026 02:26 AM
where can i find good coding practices tho ?
10-26-2026 02:44 AM
Hi Tim,
@Timfromcofidur wrote:
where can i find good coding practices tho ?
10-26-2026 03:52 AM
thx for the ressources.
Last question, I used the vi from altenbach, it work well, but i can't manage to do it twice, on the same image.
I need the vi to first make the rectangle and trim the image around it, and then make again a rectangle and save the x,y coordinates
10-26-2026 09:41 AM
@Timfromcofidur wrote:
thx for the ressources.
Last question, I used the vi from altenbach, it work well, but i can't manage to do it twice, on the same image.
I need the vi to first make the rectangle and trim the image around it, and then make again a rectangle and save the x,y coordinates
Once you do a "save for previous" (LabVIEW 2020 or below) and attach it again, i will be able to look at your program and help.