Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

Masking regions with CWIMAQViewer

OK,

Having difficulty setting a region or mask on an image and then just sending that selected region over to CWIMAQVision.Threshold and CWIMAQVision.BasicParticle to get a pixel contrast count.
Both methods require a CWIMAQImage as the source image. I accomplish it just fine sending my entire source image, but I want to just sending something which is inside a drawn rectangle.

I have 2 CWIMAQViewer controls side by side. The first displays my raw image, the second displays my RED on BLACK Particle image. I want to draw a region on the left CWIMAQViewer and then just have what is inside that region be particle'd and show up in the right Viewer Control.

I was trying the RegionsToMask method which was putting the shape of the mask into the other CWIMAQViewer control. But I can't figure out how to pass what might be inside that Region I selected off to the Threshold & BasicParticle methods.

Any Ideas?

Thanks
0 Kudos
Message 1 of 4
(6,585 Views)
Try looking at the Histogram example that installs with IMAQ Vision under C:\Program Files\National Instruments\Vision\Examples\MSVB.NET\2. Functions\Analysis (if you are using .NET - if not, change the MSVB.NET folder to MSVB).

This example shows how to use a ROI and create a histogram from that ROI.

As for functions that do not have a mask input, use the RegionsToMask Method (CWIMAQRegions.RegionsToMask DestImage [, UseModelImage = True] [, FillValue = 255])to create a Mask from a selected Region of Interest and then use the Mask Method (CWIMAQVision.Mask ( SourceImage, MaskImage, DestImage)) to copy the portion of the image you want into another image buffer - DestImage. Then use that DestImage as the image input for your Threshold and BasicParticle methods.

I hope this helps. Good luck with your application!
0 Kudos
Message 2 of 4
(6,580 Views)
Thanks,

That works like it should with teh sample code, and I modified the sample Project called Mask so that what I selected with a Square appears in the second viewer. (The original version of that sample is a Click in the original viewer and then the contents of what fills the "Mask" picture appears in teh second viewer. Anyways,
In my project when I Select my range and copy that contents with the .MASK method the mask part of the image is copied to my second viewer as a RASTER snow image. It ain't copying like the same code in the sample.
Could my CWIMAQViewers not be U8, as I think that they must be. But if that is the case, how would I set it.
Not aswell. I can do everything fine the same Images in the MASK sample as I am trying to use in my project.

If we can get that, then we're all set.

Thanks again
0 Kudos
Message 3 of 4
(6,576 Views)
The CWIMAQImage.Type will set the image data type of the buffer you have setup. The possible Data Types for CWIMAQImageTypes are:

cwimaqImageTypeComplex–Complex.
cwimaqImageTypeHSL32–32-bit HSL.
cwimaqImageTypeI16–Signed 16-bit.
cwimaqImageTypeRGB32–32-bit RGB.
cwimaqImageTypeRGBU64–64-bit unsigned RGB.
cwimaqImageTypeSGL–Single precision.
cwimaqImageTypeU8–Unsigned 8-bit.

This is all in the IMAQ Vision for Visual Basic Reference Help which can be found at:
Start»Programs»National Instruments»Vision»Documentation»IMAQ Vision Visual Basic Reference Help.

Hopefully this will solve your problem. Good luck with the project!
0 Kudos
Message 4 of 4
(6,569 Views)