Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Break larger ROI into subsections

I think this will give you a pretty good idea of how to use the nested loops in LabVIEW. 

 

grid_of_ROIs.png

You will notice that for this setup, the program iterates through the selected image and creates ROIs based on the image size and dimensions you specify. Here is an example using a 5x5 grid.

 

grid_of_ROI_pic.PNG

 

If you wanted to overlay the ROIs in such a fashion and then have a user select which to use, you might consider the array of booleans option I mentioned before. Then, you could have another IMAQ image that actually gets processed after the user selects which ROIs to use. With the same double-loop setup, you could initialize and then index the boolean array to select the correct subsection to use or not. I hope this helps and can get you started. I attached the VI of yours that I modified. Let me know if you have any other questions about it.

Matt J - NI Tools Network
Message 11 of 23
(2,046 Views)

Thank you for your help! By setting up an boolean array of size n (n being the # of rois) I plan on adding the ability to select and deselect them after the loop is finished, or at least I am trying to do that with an event structure via a 'Mouse Down' event.

 

Here is my plan:

So bascially, if the mouse is within a boundary of an roi and there is a mouse down event while within that boundary, that roi is now 'False' or 'Off'.

 

So it goes from ForLoop(ForLoop) [nested] -> While(EventStructure(MouseDown))->update IMAQImage

 

 

As an aside, I don't follow what you mean by adding another IMAQImage, unless you mean the new image will only have the selected rois. 

0 Kudos
Message 12 of 23
(2,033 Views)

Yes that is what I meant by the other IMAQ image. I think you are on the right track now. Good luck! Let us know if we can help out further.

Matt J - NI Tools Network
0 Kudos
Message 13 of 23
(2,030 Views)

Take a look at the attached and see if it does kind of what you want.  At least with respect to selection.

 

Increment/Decrement X and Y to subdivide original image.

Randall Pursley
Message 14 of 23
(2,019 Views)

Sorry for a late response, I have been busy. Thank you everyone for your input. Would it be acceptable to continue to use this thread for some more latter devolpmental questions regarding this vi?

 

 

Thanks

 

0 Kudos
Message 15 of 23
(1,999 Views)

Feel free to ask away, we will let you know if it should be taken to another thread.

Matt J - NI Tools Network
0 Kudos
Message 16 of 23
(1,985 Views)

Thanks Matt. Thus far everything is working great! I have a couple of additions that I want to try to add to the program. I would like to hear feedback if this is possible. 

 

First, when all of the ROIs are tiled, they are perfectly aligned with no overlap in x,y (no rotations). I would like to add a multiplier to overlap each ROI by some % over its neighboors.

 

Second, is there a way where I can select multiple rois to be processed by the function below, where the unselected rois are shaded a solid color.

 

Third, I am going to extract the centroid postions of each roi that is selected to then send to a xy positioner as a movement command. 

 

My goal is to be able to tell a xy positioner where to move on a large imageplane while actively avoiding areas (centroids) that are not selected.

0 Kudos
Message 17 of 23
(1,963 Views)

Hi dbrittain,

 

1. It seems to me this would just require a little addition math. For example, if you take the left and right values, subtract them, take a certain percentage of that, then add to the right point, you could achieve an overlap. Then, you would just need to ensure this does not apply to the leftmost point or rightmost point (edges) so the RIOs stay on the image.

 

2. One way you might do this is to create an array of clusters after the array of ROIs has been made. Associate each ROI with a boolean input (by creating a cluster) the user can select or not, and fill or process the ROIs accordingly. You could initialize an array of booleans in this step based on how many ROIs you have, then have your code reach a point where it waits for the user to hit "go" or something like that to process them. This forum thread should shed some light on doing the ROI filling.

 

3. I think you could grab the centroid and program a move with these locations without too much trouble. But, how do you envision such movement to avoid your non-selected ROIs?

Matt J - NI Tools Network
0 Kudos
Message 18 of 23
(1,949 Views)

@Matt-J

The movement that I am working on is simple, I want the stage to move to each centroid coordinate in a scanning (raster scan),fashion, from one ROI to the next. Bascially, start at one corner of the total image, and move down the column of rois (move the the position of the centroid) then move one over and move up the next coloumn . If there is a deselected (or unwanted) ROI in the way of the path, move around the ROI by either going to the nearest centroid and moving up/down to get back into the column it was in before encountering the ROI to get back to the next centroid in the column it is in or end (if there is a wall of deslected rois).

 

edit:

Another possibility that I am toying with is creating a pathway that is configurable to the operator. I am not sure how that could be accomplished.

0 Kudos
Message 19 of 23
(1,943 Views)

This seems like another application for embedded For loops. If you, based on your user's selection, created a 2D array of centroids (cluster that contains x,y), you could transpose that and move thru it (via the For loops) with successive straightline moves I think. You would probably want this array to associate the centroids with some kind of indication the ROI had been selected or not (like a boolean). Perhaps a state machine would be the best way to implement this behavior. LabVIEW has some nice built-in state machine examples. What have you done toward this so far?

Matt J - NI Tools Network
0 Kudos
Message 20 of 23
(1,926 Views)