![]() |
University of Murcia ![]() |
QVImageCanvas Class ReferenceDisplayer widget for QVImage objects and other data types.
More...
|
Public Slots | |
void | circleSelectedSlot (QPoint center, float radius) |
Public Member Functions | |
QVImageCanvas (const QString name=QString(), QWidget *parent=0) | |
Image canvas constructor. | |
bool | setColor (const QString &name, const QColor &color) |
Sets the display color for a registered input property of the canvas. | |
bool | setPrintTags (const QString &name, const bool &printTags) |
bool | setRadius (const QString &name, const int &radius) |
Sets the display radius for a registered input property of the canvas. | |
void | setSaturationRange (const float low, const float high) |
Sets the saturation range to display floating point images. | |
bool | linkSelectedPolyline (QVPropertyContainer *destinationContainer, QString destinationPropName) |
Link selected polyline property with a block's input property. | |
bool | linkSelectedRectangle (QVPropertyContainer *destinationContainer, QString destinationPropName) |
Link selected rectangle property with a block's input property. | |
bool | linkSelectedPolyline (QVPropertyContainer &destinationContainer, QString destinationPropName) |
Link selected polyline property with a block's input property. | |
bool | linkSelectedRectangle (QVPropertyContainer &destinationContainer, QString destinationPropName) |
Link selected rectangle property with a block's input property. | |
virtual void | custom_viewer () |
Display user defined data types method. | |
void | setLowHigh (float low, float high) |
void | unlink () |
Completely unlinks a property holder. | |
Protected Member Functions | |
void | draw (const QVPolyline &polyline, QColor color=Qt::red, bool printTags=false) |
Class QVImageCanvas can be used to create a very flexible and useful widget to show QVImage objects. This widget is in fact a property container, and as such it will read the image to be displayed from an output dynamic property contained in another property container (usually a QVProcessingBlock object).
It is used as follows. First, the programmer must create the QVImageCanvas object in the main() function of a program; then, a link to a QVImage type property from a property holder must be created. For example:
[...] CannyBlock cannyBlock("Canny"); [...] QVImageCanvas imageCanvas; cannyBlock.linkProperty(imageCanvas,"Canny image"); [...]
When the application executes, it will automatically create a window like the following:
Zoom in button ![]() | This button zooms the image in. Canvas window doesn't change size, but the area of the image displayed becomes smaller by a factor of 4 (width and height gets divided by 2). The label of the left bottom corner displays the text z=<zoom>
|
---|---|
Zoom out button ![]() | This button divides zoom factor by 2, if it is equal or greater than 2. If the canvas window is bigger than the image at the final zoom, it is adjusted to the size of the latter.
|
Zoom restore button ![]() | This button sets zoom factor by 1, and resizes canvas window to its original size.
|
Select zoom region button ![]() | This button lets you select a rectangle in the image to zoom, adjusting zoom factor and canvas window size to it.
|
Select polyline button ![]() | This button lets you select points in the image. The created points list can then be accessed to in the program by reading the "poly select" imageCanvas output property. You can expand this button by pushing it for a few seconds, and then you will be able to select a polyline representation, a point list representation, or generate a circular polyline, by clicking and dragging.
|
Select ROI button ![]() | This button lets you select a rectangle in the image. That rectangle can be again accessed to using the "rect select" imageCanvas output property.
|
Drag mode ![]() | This button activates drag mode. With it you can move around the image displayed in the canvas window, if the zoom factor forces the canvas window to show only a sub-region of the image, by holding click and dragging on the shown image. |
In the following figure you can see a zoomed canvas window showing a sub-region of the original image:
Another interesting feature of this widget is that at a zoom factor equal or larger than 32, the canvas renders the gray-scale pixel value over every pixel if the image is gray-scale, or the three different values for each of the RGB channels over every pixel, if the image is RGB, as shown below:
The canvas also knows how to show numeric float values, when showing images of type QVImage<sFloat,1> or QVImage<sFloat,3>.
Definition at line 109 of file qvimagecanvas.h.
QVImageCanvas::QVImageCanvas | ( | const QString | name = QString() , |
|
QWidget * | parent = 0 | |||
) |
Image canvas constructor.
name | Name of the image canvas | |
parent | parent QObject of the canvas |
Definition at line 28 of file qvimagecanvas.cpp.
bool QVImageCanvas::setColor | ( | const QString & | name, | |
const QColor & | color | |||
) | [inline] |
Sets the display color for a registered input property of the canvas.
Registered properties of types QList<QPoint>, QList<QPointF>, QList<QVPolyline> and QList<QVPolylineF> are displayed in the canvas with a default color assigned by the link method. The user can specify a non-default color value using method setColor.
The following code registers an image property, and a QList<QPointF> property in an image canvas from a source block, and sets the display color of the points received from the block, through the Detected points property to be red.
QVImageCanvas imageCanvas("Harris corners"); harrisCornersDetector.linkProperty("Input image", imageCanvas); // Property "Detected points" is of type QList<QpointF> harrisCornersDetector.linkProperty("Detected points", imageCanvas); imageCanvas.setColor("Detected points", Qt::red);
name | Name of the source property to set the color. | |
QColor | Color to display the elements contained in the property. |
Definition at line 137 of file qvimagecanvas.h.
bool QVImageCanvas::setPrintTags | ( | const QString & | name, | |
const bool & | printTags | |||
) | [inline] |
bool QVImageCanvas::setRadius | ( | const QString & | name, | |
const int & | radius | |||
) | [inline] |
Sets the display radius for a registered input property of the canvas.
Some registered properties, for example points, are displayed in the canvas with a default radius size of 3. As the setColor, this method can be used to specify a display radius size different than the default.
name | Name of the source property to set the radius. | |
radius | Radius size of the property. |
Definition at line 151 of file qvimagecanvas.h.
void QVImageCanvas::setSaturationRange | ( | const float | low, | |
const float | high | |||
) |
Sets the saturation range to display floating point images.
The default saturation range to display a floating point image (QVImage<sFloat, 1> or QVImage<sFloat, 3>) is [0, 255]. This means that pixel intensity values outside that range will be set to 0 or 255, wether the intensity is below or above that range.
This method can be used to specify a different saturation range.
low | Lower value for the saturation range. | |
high | Higher value for the saturation range. |
Definition at line 385 of file qvimagecanvas.cpp.
Referenced by setLowHigh().
bool QVImageCanvas::linkSelectedPolyline | ( | QVPropertyContainer * | destinationContainer, | |
QString | destinationPropName | |||
) | [inline] |
Link selected polyline property with a block's input property.
Definition at line 167 of file qvimagecanvas.h.
Referenced by linkSelectedPolyline().
bool QVImageCanvas::linkSelectedRectangle | ( | QVPropertyContainer * | destinationContainer, | |
QString | destinationPropName | |||
) | [inline] |
Link selected rectangle property with a block's input property.
Definition at line 174 of file qvimagecanvas.h.
Referenced by linkSelectedRectangle().
bool QVImageCanvas::linkSelectedPolyline | ( | QVPropertyContainer & | destinationContainer, | |
QString | destinationPropName | |||
) | [inline] |
Link selected polyline property with a block's input property.
This is an overloaded function provided for convenience.
Definition at line 183 of file qvimagecanvas.h.
bool QVImageCanvas::linkSelectedRectangle | ( | QVPropertyContainer & | destinationContainer, | |
QString | destinationPropName | |||
) | [inline] |
Link selected rectangle property with a block's input property.
This is an overloaded function provided for convenience.
Definition at line 192 of file qvimagecanvas.h.
virtual void QVImageCanvas::custom_viewer | ( | ) | [inline, virtual] |
Display user defined data types method.
By reimplementing this method on QVImageCanvas subclasses, the developer can modify the way the objects are displayed in the canvas, or specify the way new user data type objects must be displayed.
These subclasses can create image canvas objects which display registered objects the new way.
Method custom_viewer is called whenever the canvas must be repainted, for example due to changes in the input properties or a canvas resizement. The reimplemented code for this method must read the user defined properties, and use QVImageCanvas or QWidget functionality to correctly display them.
An example custom_viewer function reimplementation follows:
void MyImageCanvas::custom_viewer() { foreach(QString propertyName, getPropertyListByType< QList< QVPolylineF > >()) { QList< QVPolylineF > polylineList = getPropertyValue< QList< QVPolylineF > >(propertyName); foreach(QVPolylineF polyline, polylineList) { // Set the color of the polyline const int pointHash = qHash(polyline.first()); draw(polyline, qvColors[pointHash % 10]); // Draw red dots on the end of the polyline getQVPainter()->setPen(Qt::red); getQVPainter()->setBrush(QBrush(Qt::red, Qt::SolidPattern)); getQVPainter()->drawEllipse(polyline.first().x()-1, polyline.first().y()-1, 3, 3); getQVPainter()->drawEllipse(polyline.last().x()-1, polyline.last().y()-1, 3, 3); } } }
Image canvas objects created from the class MyImageCanvas, which supossely inherits from QVImageCanvas will display polylines contained in input polyline lists with different colors, depending on the location of their first point, and red dots of radius 3 at the ends of each polyline.
Definition at line 235 of file qvimagecanvas.h.
void QVImageCanvas::setLowHigh | ( | float | low, | |
float | high | |||
) | [inline] |
Definition at line 238 of file qvimagecanvas.h.
void QVImageCanvas::unlink | ( | ) | [virtual] |
Completely unlinks a property holder.
Deletes all the input and output links associated to the holder. Of course, all the corresponding necessary unlinks in other property holders are also performed.
Reimplemented from QVPropertyContainer.
Definition at line 291 of file qvimagecanvas.cpp.
void QVImageCanvas::circleSelectedSlot | ( | QPoint | center, | |
float | radius | |||
) | [slot] |
Definition at line 399 of file qvimagecanvas.cpp.
void QVImageCanvas::draw | ( | const QVPolyline & | polyline, | |
QColor | color = Qt::red , |
|||
bool | printTags = false | |||
) | [protected] |
Definition at line 246 of file qvimagecanvas.cpp.