rafik
28th January 2016, 14:00
Hello,
i want to draw some points (gravity centers) in a QImage, how i can do that ? i heared about QPainter but i don't understand how doing that?
here the code i want to show the points in the fensec object
#include "otsu.h"
#include "fenetreprincipale.h"
FenetrePrincipale::FenetrePrincipale(): QMainWindow()
{
label =new QLabel(&fentroi);
label->setGeometry(100,100,400,400);
QMenu *menuFichier = menuBar()->addMenu("Fichier");
QAction *actionOuvrir = new QAction("Ouvrir", this);
QAction *actionQuitter = new QAction("Quitter", this);
menuFichier->addAction(actionOuvrir);
menuFichier->addAction(actionQuitter);
QMenu *menuTraitement = menuBar()->addMenu("Traitement");
QAction *actionBinarisation = new QAction("Binarisation", this);
menuTraitement->addAction(actionBinarisation);
QObject::connect(actionOuvrir, SIGNAL(triggered(bool)), this, SLOT(ouvrir()));
QObject::connect(actionQuitter, SIGNAL(triggered(bool)), this, SLOT(close()));
QObject::connect(actionBinarisation, SIGNAL(triggered(bool)), this, SLOT(traiterOtsu()));
}
void FenetrePrincipale::ouvrir()
{
nomFichier = QFileDialog::getOpenFileName(this, tr("Open File"),"C:/Users/amine/Downloads");
image = new QImage(nomFichier);
QPixmap pixmap;
pixmap.convertFromImage(*image);
label->setPixmap(pixmap);
fentroi.show(); // fentroi (fenetre qui affiche l'image) attribut de fenetre principale
label->update();
}
void FenetrePrincipale::traiterOtsu()
{
OtsuAlgo traitement(nomFichier);
traitement.traiter(nomFichier);
traitement.binarisation();
QImage *im = new QImage(traitement.getImage());
QLabel *label1 = new QLabel(&fenSec);
label1->setGeometry(100,100, 400, 400);
label1->setPixmap(QPixmap::fromImage(*im));
QLCDNumber *lcd = new QLCDNumber(&fenSec);
lcd->move(70,70);
lcd->setSegmentStyle(QLCDNumber::Flat);
lcd->display(traitement.getSeuil());
fenSec.show();
traitement.detection();
}
if some one can help me
thank you.
i want to draw some points (gravity centers) in a QImage, how i can do that ? i heared about QPainter but i don't understand how doing that?
here the code i want to show the points in the fensec object
#include "otsu.h"
#include "fenetreprincipale.h"
FenetrePrincipale::FenetrePrincipale(): QMainWindow()
{
label =new QLabel(&fentroi);
label->setGeometry(100,100,400,400);
QMenu *menuFichier = menuBar()->addMenu("Fichier");
QAction *actionOuvrir = new QAction("Ouvrir", this);
QAction *actionQuitter = new QAction("Quitter", this);
menuFichier->addAction(actionOuvrir);
menuFichier->addAction(actionQuitter);
QMenu *menuTraitement = menuBar()->addMenu("Traitement");
QAction *actionBinarisation = new QAction("Binarisation", this);
menuTraitement->addAction(actionBinarisation);
QObject::connect(actionOuvrir, SIGNAL(triggered(bool)), this, SLOT(ouvrir()));
QObject::connect(actionQuitter, SIGNAL(triggered(bool)), this, SLOT(close()));
QObject::connect(actionBinarisation, SIGNAL(triggered(bool)), this, SLOT(traiterOtsu()));
}
void FenetrePrincipale::ouvrir()
{
nomFichier = QFileDialog::getOpenFileName(this, tr("Open File"),"C:/Users/amine/Downloads");
image = new QImage(nomFichier);
QPixmap pixmap;
pixmap.convertFromImage(*image);
label->setPixmap(pixmap);
fentroi.show(); // fentroi (fenetre qui affiche l'image) attribut de fenetre principale
label->update();
}
void FenetrePrincipale::traiterOtsu()
{
OtsuAlgo traitement(nomFichier);
traitement.traiter(nomFichier);
traitement.binarisation();
QImage *im = new QImage(traitement.getImage());
QLabel *label1 = new QLabel(&fenSec);
label1->setGeometry(100,100, 400, 400);
label1->setPixmap(QPixmap::fromImage(*im));
QLCDNumber *lcd = new QLCDNumber(&fenSec);
lcd->move(70,70);
lcd->setSegmentStyle(QLCDNumber::Flat);
lcd->display(traitement.getSeuil());
fenSec.show();
traitement.detection();
}
if some one can help me
thank you.