|
latest version v1.9 - last update 24 Nov 2005 |
|
#include <ltiViewer.h>
Inheritance diagram for lti::viewer:


Public Member Functions | |
| viewer (const std::string &title="lti::viewer", const float contrast=1.0f, const float brightness=0.0f, const int zoom=0, const bool labelMap=false) | |
| viewer (const parameters &par) | |
| viewer (const viewer &other) | |
| virtual | ~viewer () |
| virtual const char * | getTypeName () const |
| virtual bool | show (const image &data) |
| virtual bool | show (const matrix< float > &data) |
| virtual bool | show (const matrix< double > &data) |
| virtual bool | show (const matrix< int > &data) |
| virtual bool | show (const matrix< ubyte > &data) |
| virtual bool | show (const histogram1D &data) |
| virtual bool | show (const histogram2D &data) |
| virtual bool | show (const vector< double > &data) |
| virtual bool | show (const vector< float > &data) |
| virtual bool | show (const vector< int > &data) |
| virtual bool | show (const vector< ubyte > &data) |
| bool | hide () |
| viewer & | copy (const viewer &other) |
| virtual viewerBase * | clone () const |
| bool | lastClickedPosition (point &pos) const |
| point | waitButtonPressed (const bool reportOnlyValidPos=false) const |
| int | lastKey () const |
| int | waitKey () const |
| point | waitKeyOrButton (bool &key, bool &button) const |
Parameters | |
| const parameters & | getParameters () const |
| virtual bool | setParameters (const viewerBase::parameters ¶m) |
| void | setPosition (const point &p) |
| point | getPosition () const |
| void | setSize (const point &p) |
| point | getSize () const |
Protected Member Functions | |
| void | ensureWindow (const int newWnd) |
| parameters & | getParameters () |
Protected Attributes | |
| int | wnd |
| mainWindow * | wnds [4] |
| viewerFunctor * | master |
Static Protected Attributes | |
| static const int | winTypes |
Classes | |
| class | configChannelFixed |
| Configuration Dialog for viewer of images of fixed point scalar values, like channel8 or matrix<int>. More... | |
| class | configChannelFloat |
| Configuration Dialog for viewer of images of floating point scalar values, like channel or matrix<double>. More... | |
| class | configDialog |
| Parent class for all types of configuration dialogs for the normal viewer. More... | |
| class | configImage |
| Configuration Dialog for viewer of images of rgbPixel elements. More... | |
| class | configVector |
| Configuration Dialog for viewer of vectors. More... | |
| class | mainWindow |
| Abstract class for all main windows for the different data types. More... | |
| class | mainWndChannelFixed |
| Main Window for channels of fixed point values. More... | |
| class | mainWndChannelFloat |
| Main Window for channels of floating point values. More... | |
| class | mainWndImage |
| Main Window for color images. More... | |
| class | mainWndVector |
| Main Window for vectors. More... | |
| class | parameters |
| The parameters for the class viewer. More... | |
The GTK-GUI Toolkit is required to compile this object.
The use of the lti::viewer is very simple. Each viewer administrates one window, and this window will exist as long as the viewer object exists. This means, if you destroy the viewer-object, the window will be automatically destroyed.
To use the viewer see following example:
#include "ltiImage.h" #include "ltiSplitImage.h" #include "ltiViewer.h" #include "ltiBMPFunctor.h" ... lti::image img; // an image lti::channel chnl; // a channel lti::splitImageTorgI splitter; // a functor to get the intensity channel lti::loadBMP loader; loader.load("yourImage.bmp",img); // load the image in the given file splitter.getIntensity(img,chnl); // get the intensity channel of the img lti::viewer view1,view2; view1.show(img); // open a window and show the image view2.show(chnl); // open a new window and show the // intensity channel. ... // until the end of the execution block the images will be displayed. // When view1 and view2 are destroyed, their windows will disappear!
If you press the left-button of the mouse on a pixel, the value of this pixel will be displayed on the status bar.
You can configure some display-options by using the viewer::parameters.
If you press the right-mouse button an options-dialog will be displayed. You can control directly some display parameters (brightness, contrast, zoom, etc.) You can also save exactly the image you are viewing pressing the button "Save" on the options dialog. See lti::viewer::parameters for more information
The statistic values computed will correspond always to intensity values, even for color images. Remember that intensity is defined as (R+G+B)/3.
The method waitButtonPressed() allows you to block the execution of your program until the user clicks somewhere on the viewer window. The position of the pixel clicked will be returned.
Known Bugs
The multithreaded nature of the viewer functor has shown a few bugs. Until a proper fix is provided, the following workaround have to be done:
1. A crash at the very end of the application can be expected since the destruction of window handlers is done by two threads simultaneously. The secondary GTK+ thread is the only one that should do this, but the main thread destroys everything open at the end of the application, which also include stuff that secondary thread should do. To avoid this conflict you can force termination of the secondary "GTK-Server" thread explicitely:
#include "ltiGtkServer.h" #include "ltiTimer.h" int main() { // ... your code here // ... try to hide all viewers that aren't used any more // lti::passiveWait(50000); // wait 50ms that all viewers end its // event handling lti::gtkServer::shutdown(); // stop the server (secondary thread) lti::passiveWait(50000); // wait 50ms that all viewers end its // event handling return 1; }
Please note that the shutdown() method is called at the very end of the main method. This must be done this way, because after removing the GTK Server, there is no way to start it again in order to create or display the data on viewers. The last passiveWait forces to wait until everything that has to do with viewers is removed.
2. The second bug has to do with a race condition when two viewers try to display data at almost the same time. Even if the LTI-Lib calls the locking mechanisms of GTK, they don't seem to work and the application ends in a dead-lock. The workaround is to avoid calling show() methods successively, separating them by small pauses. This has to be done only once, before the windows are created:
lti::viewer v1,v2; // two viewers v1.show(img1); // show an image lti::passiveWait(50000) // wait 50ms (WORKAROUND FOR BUG) v2.show(img2); // show another image for (int i=0;i<10;i++) { v1.show(imgs[i]); // show images, since the viewer was already // displayed, the problem does not occur anymore. }
A new viewer generation is being developed to fix this awful bugs.
|
||||||||||||||||||||||||
|
construct a viewer with the given title, contrast and brightness
|
|
|
constructor with given parameters
|
|
|
copy constructor
|
|
|
destructor
|
|
|
returns a pointer to a clone of the functor.
Implements lti::viewerBase. |
|
|
copy data of "other" functor.
|
|
|
Ensure that the wnds array contains a valid window with the actual parameters at each given position.
|
|
|
returns used parameters as a read/write reference
Reimplemented from lti::viewerBase. |
|
|
returns used parameters
Reimplemented from lti::viewerBase. |
|
|
get position of the window
|
|
|
get size of the window
|
|
|
returns the name of this type ("viewer")
Reimplemented from lti::viewerBase. |
|
|
hides the display window
Implements lti::viewerBase. |
|
|
Get the last clicked position and write the result at the given parameter. If this position lies within the displayed image, the returned value is true, otherwise false. This method does not block the program execution. It just returns the last clicked position (which can be seen in the status bar) Note that the clicked position can be out of range.
|
|
|
return the last pressed key This method does not block the program execution. It just returns the value of the last key pressed.
|
|
|
set the parameters to be used
Reimplemented from lti::viewerBase. |
|
|
set position of the window
|
|
|
set size of the window
|
|
|
shows a vector of double
|
|
|
shows a vector of double
Reimplemented from lti::viewerBase. |
|
|
shows a vector of double
Reimplemented from lti::viewerBase. |
|
|
shows a vector of double
Reimplemented from lti::viewerBase. |
|
|
shows histogram as vector of double
|
|
|
shows histogram as vector of double
|
|
|
shows a channel
|
|
|
shows a channel
Reimplemented from lti::viewerBase. |
|
|
shows a matrix of doubles as a channel
Reimplemented from lti::viewerBase. |
|
|
shows a channel
Reimplemented from lti::viewerBase. |
|
|
shows a color image.
Implements lti::viewerBase. |
|
|
Wait until the user clicks somewhere on the image/vector and returns the clicked position. Note that the clicked position can be out of range, unless you specify with the parameter, that you expect only in-image points.
|
|
|
Wait until the user press some key while the viewer window is active and return the code of the key pressed.
|
|
||||||||||||
|
Wait until the user presses a key or a mouse button.
|
|
|
This is the master who paints everything nice.
|
|
|
Number of different window types.
|
|
|
The current used window (the index in the wnds vector.
|
|
|
Window instance for channels of fixed point arithmetic.
|