Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Freehand Draw on Vision Container Image - Make it part of Image

Solved!
Go to solution

Hello Folks -

 

Want to do a freehand draw on an 8-bit grayscale image in  a Vision Container.  I then want to merge that draw with the actual image.  I assume that the draw resides in an overlay.  Vision has a merge overlay command which requires RGB destination.  I then used the IMAQ Extract SingleColorPlane to extract the intensity plane from the RGB image so that I can get back to single plane (U8) format to use IMAQ ImagetoArray fx to get to array.  I tried extracting a number of the different types of planes but do not see my drawn line on the resulting array (which I am viewing in an intensity graph).  I only see the original image.

 

Any thoughts on best way to accomplish a merging of draw and original image?

 

Thanks,

 

Don

0 Kudos
Message 1 of 12
(6,771 Views)

Don,

 

Can you look at the image that comes out of merge overlay?  Does it have the freehand drawing on it?  If not, it isn't an overlay and you will need to solve that problem.

 

If it is actually an ROI, you will need to get the ROI from the vision container, then convert the ROI to an overlay before merging overlays.

 

If it is being merged properly, you need to pick the color plane that would contain the freehand drawing.  If the drawing is green, you would need to extract the green plane.  I would draw in white or black to make it easier.

 

Bruce

Bruce Ammons
Ammons Engineering
Message 2 of 12
(6,757 Views)

Hi Bruce -

 

I am including some crude example code I put together but still missing a piece to make this work.  Maybe you can take a look and let me know what is missing.  I merge the ROI and image but cannot extract the merged plane info.  The Image Dst  Out on the Merge Overlay fx is automatically converted to RGB type image.

 

I have also built a draw module to do a freehand draw on an intensity graph using straight LabVIEW (no Vision), and would also like to do the same thing in terms of merging the drawn line with the intensity graph image.  In this case, the drawn line resides in the  'plot images' property node, and here again it is not clear to me how to easily get this information into the image.  I am posting this code also.

 

It seems like that in both cases, one could track the positions of the draw and do an array replacement at the x,y locations at which the line is drawn.  But before I went to that extent, I thought we might be able to do it an easier way close to how the Vision-based code works

 

thanks,

 

Don

Download All
Message 3 of 12
(6,749 Views)
Solution
Accepted by topic author DonRoth

I am posting an example showing my current quick best effort at a non-Vision, non-overlay solution to this problem. This approach was alluded to in my prior post.  I will cross-post this in the LabVIEW forum also since it is a pure-LabVIEW solution.  It is hard for me to believe that we can't directly get at that 'overlay' information using either Vision or LabVIEW.

 

Interpolation is required after the line draw to obtain all cursor positions that the pen (cursor) moved over. I used factor of 10 and spline interpolation.

 

Drawing points on the intensity graph, rather than lines, did not work well because with my code, I am clearing missing events related to grabbing all of the cursor positions.  

 

Feel free to let me know if you can do better.

 

Sincerely,

 

Don

Message Edited by DonRoth on 11-06-2009 09:53 AM
Message 4 of 12
(6,730 Views)

Hey Don -

 

Just a quick note about a question you posed in your second post. You had mentioned that you had a little trouble extracting the Red plane as a U8 image. One thing that you might want to try is to create a new image buffer, set it to a U8 image type and wire that into the corresponding Hue input to the IMAQ ExtractColorPlane.vi. This will allow you to get an 8bit grayscale out with your 'freehand' ROI converted to an overlay and merged with your original image; while at the same time keeping your image as an 8-bit image. 

 

Let me know if I am way off base. But take a look at the attached example. It is much more simplified than what you already have and there isn't much new, except of the creation of a new image buffer. 

Message Edited by BCho on 11-06-2009 10:26 AM
Hope this helps.
-Ben

WaterlooLabs
0 Kudos
Message 5 of 12
(6,720 Views)
Hi Ben - Can you save to 8.5 or post a simple screen shot?....Don
0 Kudos
Message 6 of 12
(6,713 Views)

Hey Don -

 

Sorry about that. Here you go.

 

 

Hope this helps.
-Ben

WaterlooLabs
0 Kudos
Message 7 of 12
(6,706 Views)

Yes, this seems to work well.  My mistake was using the IMAQ ROIToMask fx instead of the IMAQ OverlayROI fx.  And actually if you use the IMAQ ExtractSingleColorPlane fx, you do not need to create an extra image buffer.  Now what is very interesting to note is that the merge produces a similar, but not identical line, very much like the non-Vision solution I have posted.

 

Thanks a bunch for looking at this!

 

Sincerely,

 

Don

Message Edited by DonRoth on 11-06-2009 11:59 AM
0 Kudos
Message 8 of 12
(6,702 Views)
merge-overlay.png...And here is the final example code as well.....Don
Message Edited by DonRoth on 11-06-2009 12:11 PM
0 Kudos
Message 9 of 12
(6,699 Views)
0 Kudos
Message 10 of 12
(6,672 Views)