Define "Don't Care" regions for Minos programmatically

minos
pixeloverlay
#1

Hi,

I’m aware that I have the option to set “Don’t Care” regions/pixels for Minos instances. I was wondering how to do that programmatically?

#2

Hi,

For the Don’t Care mask, CVB uses an overlay image. First one has to create an overlay image by using CreateOverlayImage() and thus enabling the image to carry an overlay. In an overlay-enabled image, the lower-most valued bit of the image data is reserved for overlays. In Minos, this bit is used to define Don’t Care regions/pixels; If the bit is set to 1 it is a Don’t Care pixel, if the bit is 0 it is no Don’t Care, it’s like a binary mask.

The method CreateOverlayImage() sets all bits for the whole image to 0 automatically when first used and one only has to flip the bits for the desired Don’t Care points.
Overlay-enabled images will be displayed with colored Don’t Care points automatically if displayed with a CVB Display.

I hope this helps. :slight_smile:

#3

To elaborate further: It is possible, but not always necessary to descend all the way down to the level of bit manipulation for setting the “don’t care” regions. There are basically three options:

  1. Since Common Vision Blox 12.00.000 the CVCImg.dll exports a set of functions that can be used for “painting” inside a Common Vision Blox image. Unlike what the overlay plugins do, the changes made by these functions are persistent as they are carried out on the pixel data level. The functions cover the typical use cases: Draw a line, draw a rectangle, draw an ellipse. Their names are DrawLineInImage, DrawCircleInImage, FillCircleInImage, DrawAreaInImage, FillAreaInImage, DrawEllipseInImage and FloodFillBitwise.
    Each of these functions supports a parameter of type TDrawMode that defines how the functions’ intensity parameter is to be applied to the image’s pixels. For an image with 8 bits per pixel using TDrawMode::DM_AND together with an intensity of 0xfe = 254 the lowest bit will be erased when painting, effectively removing the don’t care point. TDrawMode::OR together with an intensity of 0x01 = 1 on the other hand will set the don’t care points.
    These functions are used inside the TeachBench application for manipulating the don’t care points of e.g. Minos Training Set images.
  2. Since almost its earliest versions, the Common Vision Blox Display Control has been supporting interactive painting/erasing of the don’t care points. If the image pointed to by the display’s Image property is an overlay-capable image as pointed out by @Frank and the LeftButtonMode property of the display control has been set to LB_DRAWPOINT, LB_DRAWFILL, LB_DRAWLINE or LB_DRAWRECT then the user can directly modify the don’t care pixels by painting inside the display (hold left mouse button down and move the mouse). The control’s DrawErase property specifies whether the pixels are to be set (DrawErase == FALSE) or if they are to be erased (DrawErase == TRUE).
  3. It’s of course always possible to modify the pixel data directly with the information retrieved with GetImageVPA (CVCImg.dll) or GetLinearAccess (CVCUtilities.dll). Code that does this would like similar to this:
   unsigned char *base = 0;
   PVPAT vpa = 0;
   GetImageVPA(img, 0, reinterpret_cast<void**>(&base), &vpa); 
   // loops over all lines and columns...
   for (y = 0 ; y < height ; ++y) 
   {  
     unsigned char* line = base + vpa[y].YEntry;  
     for (x = 0 ; x < width ; ++x)
     {
       unsigned char* pPix = reinterpret_cast<unsigned char*>(line + vpa[x].XEntry);
       // now you can either...
       *pPix = *pPix | 1;    // set lowest bit
       // ... or
       *pPix = *pPix & 0xfe; // unset lowest bit
     }
   }
#4

Thank you for the extensive explanation!