PARP Research Group University of Murcia, Spain


QVImageCanvas Class Reference
[Graphical User Interface]

Displayer widget for QVImage objects and other data types. More...

#include <QVImageCanvas>

Inherits QVPropertyContainer.

List of all members.

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)


Detailed Description

Displayer widget for QVImage objects and other data types.

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:

qvimagecanvas_penguin.png

You can see it has a zoom number indicator (z = 1), horizontal and vertical rules (in pixels), and some buttons. These can be used to control zooming and moving around a zoomed area of the image. A detailed explanation of each one follows:

Zoom in button
qvimagecanvas_zoomin.png
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>
where <zoom> is a number indicating the zoom factor that divides width and height in the actual zoom level.

Zoom out button
qvimagecanvas_zoomout.png
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
qvimagecanvas_zoomrestore.png
This button sets zoom factor by 1, and resizes canvas window to its original size.

Select zoom region button
qvimagecanvas_zoomregion.png
This button lets you select a rectangle in the image to zoom, adjusting zoom factor and canvas window size to it.

Select polyline button
qvimagecanvas_polyline.png
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
qvimagecanvas_roi.png
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
qvimagecanvas_drag.png
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:

qvimagecanvas_penguinpixels.png

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:

qvimagecanvas_penguinpixelnumbers.png

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 108 of file qvimagecanvas.h.


Constructor & Destructor Documentation

QVImageCanvas::QVImageCanvas ( const QString  name = QString(),
QWidget *  parent = 0 
)

Image canvas constructor.

Parameters:
name Name of the image canvas
parent parent QObject of the canvas

Definition at line 28 of file qvimagecanvas.cpp.


Member Function Documentation

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);

Parameters:
name Name of the source property to set the color.
QColor Color to display the elements contained in the property.

Definition at line 136 of file qvimagecanvas.h.

bool QVImageCanvas::setPrintTags ( const QString &  name,
const bool &  printTags 
) [inline]

Todo:
document

Definition at line 140 of file qvimagecanvas.h.

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.

Parameters:
name Name of the source property to set the radius.
radius Radius size of the property.

Definition at line 150 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.

Parameters:
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.

Todo:
expand this documentation

Definition at line 166 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.

Todo:
expand this documentation

Definition at line 173 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.

See also:
linkSelectedPolyline(QVPropertyContainer *, QString)

Definition at line 182 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.

See also:
linkSelectedRectangle(QVPropertyContainer *, QString)

Definition at line 191 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 234 of file qvimagecanvas.h.

void QVImageCanvas::setLowHigh ( float  low,
float  high 
) [inline]

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]

Todo:
¿El ROI debe mandarse al block mientras se está arrastrando, o solo cuando se suente el ratón? -> Hacer concilio
Todo:
¿Cuantos puntos debe contener la polilínea de la circunferencia, uno por pixel o menos? -> Hacer concilio

Definition at line 399 of file qvimagecanvas.cpp.

void QVImageCanvas::draw ( const QVPolyline polyline,
QColor  color = Qt::red,
bool  printTags = false 
) [protected]

Todo:
La posicione de los píxeles esta desplazado respecto a los clic de raton, esto se ve a la hora de pintar polilineas o seleccionar ROIs al máximo zoom, queriendo ajustar la precisión al pixel.

Definition at line 246 of file qvimagecanvas.cpp.


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



QVision framework. PARP research group, copyright 2007, 2008.