From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

NI VideoMASTER and NI AudioMASTER

cancel
Showing results for 
Search instead for 
Did you mean: 

IMAQ Color Match Decreases with Multiple ROIs

I think I may be doing something wrong...

 

I'm doing a color match between a reference and a test image.  So far it appears to work well without any ROIs specified.  Before I go any further I should probably tell you guys what I'm trying to achieve; I want to select multiple ROI regions on the reference image then do a color match for those regions in the test image.    The problems start when I select more than 1 ROI on the reference image, as seen below.  The image shown below is the front panel of my vi, you will notice that there are multiple ROI regions selected on the reference image, I expected to get a score of 1000 (the score is 1 - 1000) but as you can see the score is 687.  I'm using the IMAQ colormatch.vi for scoring the images. 

 

When I select 1 ROI where I know there will not be any pentagons I get a score of 1000.  When an ROI is NOT selected I get a score of 868 which is expected because of the red pentagons on the test image. So it appears that the ROI functionality is somewhat working just not when I select more than one. 

 

I have attached the main vi which is called video.vi and a subvi called Image Color Compare.vi. 

 

Front Panel

Download All
0 Kudos
Message 1 of 5
(11,059 Views)

Hi Daniel,

 

I can't actually run your Video VI because I'm missing a few type definitions; however, I can run Image Color Compare. I noticed that you are using the name "test" for both IMAQ Create functions, instead of unique names. Also, your images are set to greyscale (I'm assuming) in order to use the histograph function, but there doesn't appear to be any code which compares based on color rather than greyscale intensity.

 

Also, where in Video.vi is Image Color Compare used as a SubVI? I looked through the code but I was unable to find its location.

 

 

0 Kudos
Message 2 of 5
(11,031 Views)

About the name test, I never meant to upload Image Color Compare.vi  Please look at the video.vi and ignore the other vi.  In Video.vi you will noticed a while loop in the bottom with a case called Color Match, that is where the problem is at. 

 

I have reposted the VIs that I meant to post originally. By the way this new Video.vi may already have the fix for this.  

Download All
0 Kudos
Message 3 of 5
(11,026 Views)

How are your results affected if you change the Color Sensitivity on the IMAQColorLearn function to Medium or Low?

0 Kudos
Message 4 of 5
(11,010 Views)

I see. It sounds like you are trying to do a multi-ROI color match, but the IMAQ colormatch.vi function is only designed for single-ROI color matching.

One way to work around this is to use the IMAQ image arithmetic.vi function to combine the multiple ROIs into a single ROI. You can then use the IMAQ colormatch.vi function to match the test image to this single ROI.

Here are the steps involved:

  1. Create a new image that is the same size as the reference image.
  2. For each ROI in the reference image, copy the pixels from the ROI to the corresponding location in the new image.
  3. Use the IMAQ colormatch.vi function to match the test image to the new image.

Here is an example of how to do this in LabVIEW:

// Create a new image that is the same size as the reference image. Image newImage = Image.create(refImage.width, refImage.height);

// For each ROI in the reference image, copy the pixels from the ROI to the corresponding location in the new image. for (int i = 0; i < refROIs.size(); i++) { ImageROI refROI = refROIs.get(i); ImageROI newROI = new ImageROI(newImage, refROI.x, refROI.y, refROI.width, refROI.height); newROI.copyFrom(refROI); }

// Use the IMAQ colormatch.vi function to match the test image to the new image. double score = IMAQ.colormatch(testImage, newImage);

I hope this helps! Let me know if you have any other questions.

0 Kudos
Message 5 of 5
(1,371 Views)