Into

Modules

Documentation

classPiiImagePieceJoiner

#include <PiiImagePieceJoiner.h>

An operation that combines adjacent sub-images to larger compounds.

Inherits PiiDefaultOperation

Description

This operation is used in situations where multiple sub-images are extracted from a single large image and selected sub-images need to be combined to form larger sub-images. The main use is in recognizing large defects in defect detection. Each sub-image has a label that tells the class of the sub-image. Adjacent sub-images with the same class label are joined together to form continuous regions.

Inputs

imagethe large image the pieces are extracted from (any matrix or image type)
locationan optional input specifying the location of the input area within a larger image. If this input is connected, emitted locations will be subtracted by the upper left corner of the input location. The location is expected to be a PiiMatrix<int> with one row and at least two columns. The first two elements of the matrix are treated as the (x,y) coordinates of the upper left corner. This input is always coupled with the image input.
areaa rectangle bounding a sub-image within the large image. Multiple rectangles may be read for each large image. (1-by-4 PiiMatrix<int>, interpreted as a PiiRectangle). This inputs works in sync with label and assumes objects at a higher flow level than image. Suitable input can be obtained for example from PiiImageSplitter.
labelan integer that labels the incoming area. This input is optional. If it is not connected, -1 will be used. (any primitive type, converted to an int)

Outputs

imageany number of sub-images extracted from the main image. The sub-images are created by finding the bounding box of all incoming rectanges that are neighbors to each other. (any matrix or image type)
locationthe location of the compound sub-image with respect to the large image. (1-by-4 PiiMatrix<int>, interpreted as a PiiRectangle)
labelthe label of the compound sub-image.

Properties

The color for transparent parts of the image.

bool

A flag that indicates whether the default label (0) is discarded or not.

bool

A flag that indicates whether the piece joiner uses transparency or not.

Constructors and destructor

Public member functions

virtual void
(
  • bool reset
)

Checks the operation for execution.

bool
bool
void
void
(
  • bool discard
)
void
(
  • bool transparent
)

Protected member functions

virtual void

Executes one round of processing.

virtual void
( )

Informs the operation about synchronization events.

Property details

  • QColor backgroundColor

    [read, write]

    The color for transparent parts of the image.

    You need to use RGBA for real transparency. The default value is black, which isn't really transparent, but works also for images with only three color channels. The background color has no effect on complex-valued matrices, for which zero is always used as the background. For gray-level images, the red channel is used.

  • bool discardDefault

    [read, write]

    A flag that indicates whether the default label (0) is discarded or not.

    By default, all sub-images labeled with zero are not considered in joining the components. Set to false to make the default label also form connected components.

  • bool transparent

    [read, write]

    A flag that indicates whether the piece joiner uses transparency or not.

    Transparency might be needed if the joined images don't form a rectangular area. For example, if three pieces are joined as shown below, background color is used for the piece marked with a question mark. If transparency is not in use, the missing slot is filled with original image data.

    +---+---+
    |   |   |
    +---+---+
      ? |   |
        +---+
    

    Note that transparent mode is not as efficient as the non-transparent one because original image data cannot be shared.

Function details

  • PiiImagePieceJoiner

    ()
  • QColor backgroundColor

    ()
  • virtual void check

    (
    • bool reset
    )
    [virtual]

    Checks the operation for execution.

    This function creates a suitable flow controller by calling createFlowController(). It then sets the flow controller to the active processor and sets the processor as the input controller for all inputs.

    If you change socket groupings in your overridden implementation, please call PiiDefaultOperation::check() after that. Otherwise, your new groupings will not be in effect.

    Reimplemented from PiiDefaultOperation.

  • bool discardDefault

    ()
  • bool isTransparent

    ()
  • void setBackgroundColor

    ( )
  • void setDiscardDefault

    (
    • bool discard
    )
  • void setTransparent

    (
    • bool transparent
    )
  • virtual void process

    ()
    [protected, virtual]

    Executes one round of processing.

    This function is invoked by the processor if the necessary preconditions for a new processing round are met. This function does all the necessary calculations to create output objects and sends them to output sockets.

    Calls to process(), syncEvent(), and setProperty() are synchronized and cannot occur simultaneously. PiiDefaultOperation ensures this by locking processLock() for reading before calling process().

    Note: With time-consuming operations, one should occasionally check that the operation hasn't been interrupted, i.e. that state() returns Running.

    Exceptions
    PiiExecutionException

    whenever an unrecoverable error occurs during a processing round, the operation is interrupted, or finishes execution due to end of input data.

    Reimplemented from PiiDefaultOperation.

  • virtual void syncEvent

    ( )
    [protected, virtual]

    Informs the operation about synchronization events.

    The most typical use of this function is to see when all objects in an input group and all of its child groups have been received. For example, if the operation reads large images from one input and a number of sub-images for each large image from another input, a sync event is sent whenever all the small images that correspond to one large image have been processed. Your implementation may then either just record the synchronized state or to send any buffered data. The default implementation does nothing.

    Calls to process(), syncEvent(), and setProperty() are synchronized and cannot occur simultaneously. PiiDefaultOperation ensures this by locking processLock() for reading before calling syncEvent().

     void MyOperation::syncEvent(SyncEvent* event)
     {
       if (event->type() == SyncEvent::EndInput &&
           event->groupId() == _pLargeImageInput->groupId())
         doWhateverNeededNow();
     }
    

    Reimplemented from PiiDefaultOperation.

Notes (0)

Add a note

Not a single note added yet. Be the first, add yours.