UsTK : Ultrasound ToolKit  version 2.0.1 under development (2023-12-07)
usElastographyDisplayWidget.cpp
1 /****************************************************************************
2  *
3  * This file is part of the ustk software.
4  * Copyright (C) 2016 - 2017 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * ("GPL") version 2 as published by the Free Software Foundation.
9  * See the file LICENSE.txt at the root directory of this source
10  * distribution for additional information about the GNU GPL.
11  *
12  * For using ustk with software that can not be combined with the GNU
13  * GPL, please contact Inria about acquiring a ViSP Professional
14  * Edition License.
15  *
16  * This software was developed at:
17  * Inria Rennes - Bretagne Atlantique
18  * Campus Universitaire de Beaulieu
19  * 35042 Rennes Cedex
20  * France
21  *
22  * If you have questions regarding the use of this file, please contact
23  * Inria at ustk@inria.fr
24  *
25  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27  *
28  * Authors:
29  * Marc Pouliquen
30  *
31  *****************************************************************************/
32 
38 #include <visp3/ustk_gui/usElastographyDisplayWidget.h>
39 #ifdef VISP_HAVE_OPENMP
40 #include <omp.h>
41 #endif
42 
43 #if (defined(USTK_HAVE_VTK_QT) || defined(USTK_HAVE_QT5)) && defined(VISP_HAVE_MODULE_USTK_ELASTOGRAPHY)
44 
49  : m_label(NULL), m_QImage(), m_pixmap(), m_rgbBitmap(NULL), m_bitmapSize(0)
50 {
51  this->setMinimumSize(50, 50);
52  m_label = new QLabel(this);
53  m_label->setMinimumSize(50, 50);
54  m_label->autoFillBackground();
55 }
56 
61 
66 void usElastographyDisplayWidget::updateFrame(const vpImage<vpRGBa> elastographyImage)
67 {
68  if (m_bitmapSize != elastographyImage.getSize() * 3) {
69  m_rgbBitmap = new uchar[elastographyImage.getSize() * 3];
70  m_bitmapSize = elastographyImage.getSize() * 3;
71  }
72 // loop on every pixel
73 #ifdef VISP_HAVE_OPENMP
74 #pragma omp parallel for
75 #endif
76  for (int i = 0; i < (int)elastographyImage.getSize(); i++) {
77  m_rgbBitmap[i * 3] = elastographyImage.bitmap[i].R;
78  m_rgbBitmap[i * 3 + 1] = elastographyImage.bitmap[i].G;
79  m_rgbBitmap[i * 3 + 2] = elastographyImage.bitmap[i].B;
80  }
81  m_QImage = QImage(m_rgbBitmap, elastographyImage.getWidth(), elastographyImage.getHeight(),
82  elastographyImage.getWidth() * 3, QImage::Format_RGB888);
83  // m_QImage.save("qimage.png");
84  QImage I = m_QImage.scaled(this->width(), this->height());
85  // I.save("qimageScaled.png");
86  m_pixmap = QPixmap::fromImage(I);
87  m_pixmap.save("qpixmap.png");
88  m_label->setPixmap(m_pixmap);
89  m_label->update();
90 }
91 
93 {
94  m_label->resize(event->size());
95  QImage I = m_QImage.scaled(this->width(), this->height());
96  m_pixmap = QPixmap::fromImage(I);
97  m_label->setPixmap(m_pixmap);
98  m_label->update();
99 }
100 
101 #endif
void updateFrame(const vpImage< vpRGBa > elastographyImage)