FotoSHOCK
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
Public Member Functions | Protected Member Functions | Friends | List of all members
FotoSHOCKcore::ImageOperation Class Referenceabstract

Base class for representing operation on an image. More...

#include <ImageOperation.hpp>

Inheritance diagram for FotoSHOCKcore::ImageOperation:
AddOne Average BWconversion BWconversion CurveOperation FotoSHOCKcore::ConvertPixelFormat FotoSHOCKcore::RootCreateImage FotoSHOCKcore::RootLoadImage MathOperation QGLPreviewOperation

Public Member Functions

 ImageOperation ()
 A constructor. More...
 
virtual ~ImageOperation ()
 A destructor.
 
GraphNodegetOwnerNode () const
 Get the node containing the operation. More...
 
virtual void initialize ()
 Set up the internal data which depends on the information from the GraphNode class. More...
 
virtual bool isPrepared ()
 Tell whether the operations is prepared to process image data. More...
 
virtual void runOperation (const Inputs &sources, const Outputs &dest, vector< UpdateInfo > &ROI, const long stamp)=0
 Apply the operation. More...
 
virtual bool updateROI (UpdateInfo &currentROI, UpdateInfo &parentROI)
 Update ROI in parent to fit the needs of a new ROI. More...
 
boost::shared_ptr< UpdateInforequestROI (boost::shared_ptr< UpdateInfo > currentROI)
 Get the required ROI of an input. More...
 
virtual void serialize (XmlSerializer &serializer)
 Serialize the operation using the specified serializer. More...
 
virtual void deserialize (XmlSerializer &serializer)
 Deserialize the operation using the specified serializer. More...
 

Protected Member Functions

void setOwnerNode (GraphNode *node)
 Sets the node, that contains the operation. More...
 

Friends

class GraphNode
 

Detailed Description

Base class for representing operation on an image.

The ImageOperation class provides the necessary interface which every operation have to implement.

Both runOperation() functions and getNumInputs() have to be reimplemented for every operation. The implementation of updateROI() and newROI() is optional and is usually necessary only for the operations which operates on pixel's neighborhood.

Examples:
BWconversion/BWconversion.hpp, BWconversion_direct/BWconversion_direct.hpp, and graph/example.cpp.

Constructor & Destructor Documentation

FotoSHOCKcore::ImageOperation::ImageOperation ( )

A constructor.

If you need to pass some data to the implementation of an ImageOperation, you may want to consider reimplementing the initialize() function too.

Member Function Documentation

void FotoSHOCKcore::ImageOperation::deserialize ( XmlSerializer serializer)
virtual

Deserialize the operation using the specified serializer.

Parameters
serializerreference to OperationSerializer that contains the operation's serialized data

Reimplemented in FotoSHOCKcore::RootLoadImage.

GraphNode * FotoSHOCKcore::ImageOperation::getOwnerNode ( ) const

Get the node containing the operation.

Returns
pointer to a node which contains the calling operation.
void FotoSHOCKcore::ImageOperation::initialize ( )
virtual

Set up the internal data which depends on the information from the GraphNode class.

This function is used to set up internal data of an operation, which depends on information that can be obtained only from the GraphNode containing this operation. As an example you can create lookup table which has the same type as the ImageBuffer assigned to the node.

This function is called automatically after the GraphNode containing the operation is fully constructed, including its connections to surround GraphNodes.

The initialize() function is usefull for example when you need to initialize structures depending on number of bands of an image.

Reimplemented in CurveOperation.

bool FotoSHOCKcore::ImageOperation::isPrepared ( )
virtual

Tell whether the operations is prepared to process image data.

The isPrepared() function is used to check whether all preconditions needed by the ImageOperation to work. These preconditions includes eg. initial setup from a user interface. This does not include setup done by the initialize() function.

The default implementation always returns true, ie. the ImageOperation is prepared to process image data without needing any additional setup.

Returns
true if the operation is prepared to run, false if it still needs some setup.

Reimplemented in FotoSHOCKcore::RootLoadImage, and FotoSHOCKcore::RootCreateImage.

shared_ptr< UpdateInfo > FotoSHOCKcore::ImageOperation::requestROI ( boost::shared_ptr< UpdateInfo currentROI)

Get the required ROI of an input.

By default the ROI in returned UpdateInfo points to the same memory as the ROI in the child. This means that the ROI is shared between the current node and its parent.

The ImageOperation implementation can override this behavior. This is useful since some operations needs the input to be of a different size than it's requested output.

If the requestROI() is overriden, the updateROI() should be overriden too.

Parameters
currentROIthe ROI that the operation should process
Returns
ROI that is needed by the operation to fulfill the currentROI requirement
virtual void FotoSHOCKcore::ImageOperation::runOperation ( const Inputs sources,
const Outputs dest,
vector< UpdateInfo > &  ROI,
const long  stamp 
)
pure virtual

Apply the operation.

Apply the operation on the given input ImageBuffers and output it in a destination buffer.

The source buffers and destination buffer can be considered as having the same PixelFormat except for some internal GraphManager operations.

Parameters
sourcessource buffers
destdestination buffers
ROIlist of regions where the operation should be recalculated. The specified ROI is not a hard limit, the region recalculated can be bigger than ROI.
stampidentifier which the operation should use to identify itself. That means you should set the tile stamp to this value in the implementation. The stamp can used to check whether the requested region of a buffer has been already processed by the operation to reduce the amount of processed data

Implemented in Average, AddOne, FotoSHOCKcore::ConvertPixelFormat, BWconversion, BWconversion, CurveOperation, and QGLPreviewOperation.

void FotoSHOCKcore::ImageOperation::serialize ( XmlSerializer serializer)
virtual

Serialize the operation using the specified serializer.

Implement this function when the operation has custom settings that should be saved in the project. The operation must use the serializer that is passed as a parameter to seriaze its data, as it guarantees, that the data are stored at a proper place in the project file.

If the operation implements this function, it must implement its counterpart, the deserialize() function.

Parameters
serializerreference to OperationSerializer that is used for serializing data

Reimplemented in FotoSHOCKcore::RootLoadImage, and FotoSHOCKcore::RootCreateImage.

void FotoSHOCKcore::ImageOperation::setOwnerNode ( GraphNode node)
protected

Sets the node, that contains the operation.

This function is called by the GraphNode class when a new GraphNode object is constructed.

Parameters
nodenode containing the operation.
bool FotoSHOCKcore::ImageOperation::updateROI ( UpdateInfo currentROI,
UpdateInfo parentROI 
)
virtual

Update ROI in parent to fit the needs of a new ROI.

By default it does nothing based on the assumption the ROI is shared between the parent and the current node.

Parameters
currentROIthe ROI of the operation
parentROIROI of the parent which will be updated
Returns
true if the currentROI and parentROI are different (ie. this function actually does something)

The documentation for this class was generated from the following files: