Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem Iterating Through Image via ROI Segments

Hi German Coast Guard,

 

I create image displays throughout your code to track the image.  The image display I put just after the IVA Mask from ROI within the while loops is the most interesting.  I placed a breakpoint at the same location and stepped through the code.  The image display was just black after the first iteration, which tells me that you are analyzing the part of the image that has been masked out.  You are iterating through the image because when I get to the final iteration of the inner loop I see just a strip instead of a square, which indicates that there are not enough rows of pixels left in the original image to make a complete block.  

 

Kristen H.

0 Kudos
Message 11 of 14
(1,470 Views)

Hi Kristen,

 

Thank you for your continued support.  You are correct that there are not enough pixels in the original image.  My current ROI size is 25x25 and 25 is not divisible by 640 or 480 without a remainder.  I will fix this issue in my code. 

 

 

The behavior you are observing with the ROI function is quite interesting.  Do you have any idea what could be causing this issue? 

 

 

From my understanding, the inputs to define the ROI in the "IVA Mask from ROI," which I am modifying with my nested loop, are as follows (from top to bottom): Y coordinate that defines the left edge of the ROI, X coordinate that defines the top edge of the ROI, Y coordinate that defines the right edge of the ROI, and finally the X coordinate that defines the bottom edge of the ROI.  I am overwriting the values in the global rectangle cluster during each iteration, and passing this to the IVA Mask from ROI VI.  Also, the "shrink" boolean input to the VI is true, which should extract the pixels specified and place them in a new image the size of the defined ROI.

 

Yet, according to your observations, it is not extracting the pixels, because the resulting image is always black...  I have double checked my values I am passing to define the ROI and do not think that this is causing the problem.  I am at a loss as to what could be causing this behavior.

 

Again, thank you for your continued support,

German Coast Guard

0 Kudos
Message 12 of 14
(1,460 Views)

Hi German Coast Guard!

 

I think the issue is with the masking of the original image.  When masking occurs, the area outside the masking area is set to black, so it seems that the masking is being saved and analyzed later.  If it was not "extracting the pixels," then nothing would appear in the image display.  Since, there is soemthing being displayed, we know it is iterating through the image okay.  It just is not accessing the correct image for anaylsis.  

 

Kristen H.

0 Kudos
Message 13 of 14
(1,451 Views)

Hi German Coast Guard,

 

I know we have a phone support service request open right now, but I thought I would go ahead and post my response on the forum, too, so that others can benefit as well (hopefully).

 

The IVA Mask from ROI outputs the Img Dst, which is a pointer to a buffer.  Because  IMAQ Mask (the one within IVA Mask from ROI) does not have a Img Dst wired to it, the buffer that Img Dst (output) points to is the same buffer as Img Source.  However, the buffer now contains a masked image and the part of the image that is masked out will be black.  The next time your loop iterates, Img Source is pointing to the buffer which still contains the masked image; therefore you are masking the already-once-masked image.  

 

The reason why this behavior is not seen on the first IVA Mask from ROI is because you do actually preserve the original image by placing it in another buffer.  Then once the masking is done and sent to the statisticssubVI, you pop from that other buffer.  The masked image is only sent to the statistics, not to the loop.

 

I hope this is clear!

 

Kristen H.

0 Kudos
Message 14 of 14
(1,384 Views)