Base class for representing operation on an image. More...
#include <ImageOperation.hpp>
Public Member Functions | |
ImageOperation () | |
A constructor. More... | |
virtual | ~ImageOperation () |
A destructor. | |
GraphNode * | getOwnerNode () 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 ¤tROI, UpdateInfo &parentROI) |
Update ROI in parent to fit the needs of a new ROI. More... | |
boost::shared_ptr< UpdateInfo > | requestROI (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 |
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.
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.
|
virtual |
Deserialize the operation using the specified serializer.
serializer | reference to OperationSerializer that contains the operation's serialized data |
Reimplemented in FotoSHOCKcore::RootLoadImage.
GraphNode * FotoSHOCKcore::ImageOperation::getOwnerNode | ( | ) | const |
Get the node containing the operation.
|
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.
|
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.
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.
currentROI | the ROI that the operation should process |
|
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.
sources | source buffers |
dest | destination buffers |
ROI | list of regions where the operation should be recalculated. The specified ROI is not a hard limit, the region recalculated can be bigger than ROI. |
stamp | identifier 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.
|
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.
serializer | reference to OperationSerializer that is used for serializing data |
Reimplemented in FotoSHOCKcore::RootLoadImage, and FotoSHOCKcore::RootCreateImage.
|
protected |
|
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.
currentROI | the ROI of the operation |
parentROI | ROI of the parent which will be updated |