The Region of Interest Drawn Using NI IMAQ Merge Overlay Is Not Visible at Original Image Size

Updated Nov 25, 2024

Reported In

Software

  • LabVIEW

Driver

  • NI-IMAQ

Issue Details

I want to draw a rectangle to highlight the Region of Interest (ROI) in my VI. When I use NI IMAQ Merge Overlay to place the rectangle on the image it is not visible on the image without zoom. The figures below show the problem. On the left side of the picture below, there is the image with its original size. The Red rectangle exists but isn't visible. On the right side, the image is zoomed in and the rectangle is normally visible.
issue.png 
 This issue is observed not only with rectangle ROIs but also with the other options available (square, oval, circle, etc...).

Solution

The ROI drawn might not be visible as its sideline pixels can be lost on high-resolution images when we use them with their original size. This problem can be solved by increasing the thickness of the ROI sides.

Operation Instructions (considering the rectangle example):
1. Open the attached VI called "Test Merge Overlay Shows Zoom Problem".
2. Select the path to the Image File. 
3. Run the VI. The program will create a red rectangle with given coordinates. On the figures Overlay Merged and Overlay Zoomed In you will see the same image.
    You can see that the Rectangle is not visible on the Overlay Merged image. When you zoom in on its top-left corner it will appear.
4. Proceed to the Block Diagram and disable the current Subdiagram (Named Problem) and Enable the other Subdiagram.
5. Run the VI. You will see the red Rectangle appearing on the Image Out figure and no need for Zoom.

 

The VI above increases the thickness of the Rectangle sides.  However, this approach can be considered for other ROI figures. For custom ROI (closed contour), a more generic procedure can be considered:

custom ROI.png

  1. Obtain the ROI points that build the contour. Every point/pixel represents the coordinate (X,Y) in the image.
  2. For each pair, find the neighbors for each pixel. You can use 4 (right, left, up, and down) neighbors or 8 (including diagonals). This will define how smooth is the ROI. 
  3. Filter the new coordinates to eliminate the new pixels found that belong to the current ROI or are inside it. An easy approach is to create a mask for the original image using the existing ROI. This will create a binary image that you can use to determine if the new pixel belongs to the mask (its pixel value is 1) or if it belongs to the external layer of the original ROI. 
  4. Use this list of points to create new external layers. This will define the thickness of the ROI.
  5. Apply/draw these sets of points (coordinates) to the original image using the IMAQ Overlay ROI VI.
  6. Merge the overlays with the original image using the IMAQ Merge Overlay VI if needed.

result.png