Skip to content

Commit

Permalink
histo widget updated but untested #49
Browse files Browse the repository at this point in the history
  • Loading branch information
mattrussmill committed Jun 19, 2019
1 parent a5048f0 commit 204e4af
Show file tree
Hide file tree
Showing 4 changed files with 148 additions and 319 deletions.
15 changes: 12 additions & 3 deletions histogramobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,20 @@
#include <QImage>
#include "histogramdata.h"
#include <QDebug>
#include <algorithm>

/* default constructor, creates Histogram Data */
HistogramObject::HistogramObject() : data_m(new HistogramData) {}
HistogramObject::HistogramObject(QObject *parent) : QObject(parent), data_m(new HistogramData) {}

/* constructor fills newly created histogram data from image and emits the signal declaring successful. */
HistogramObject::HistogramObject(const QImage &image) : data_m(new HistogramData)
HistogramObject::HistogramObject(const QImage &image, QObject *parent) : QObject(parent), data_m(new HistogramData)
{
if (update(image))
emit updated();
}

/* constructor that passes the shared data ptr to the shared data object */
HistogramObject::HistogramObject(const HistogramObject &hobj) : data_m(hobj.data_m) {}
HistogramObject::HistogramObject(const HistogramObject &hobj, QObject *parent) : QObject(parent), data_m(hobj.data_m) {}

/* default destructor */
HistogramObject::~HistogramObject() {}
Expand Down Expand Up @@ -90,6 +91,14 @@ int HistogramObject::getNumChannels()
return data_m->histogram.size() % 256;
}

// returns the largest value stored in the histogram
uint32_t HistogramObject::getLargest()
{
return *std::max_element(data_m->histogram.constBegin(), data_m->histogram.constEnd());
}


//generates the histogram of the passed image based on the image format
bool HistogramObject::update(const QImage &image)
{
int size;
Expand Down
7 changes: 4 additions & 3 deletions histogramobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,15 @@ class HistogramObject : public QObject
Q_OBJECT

public:
HistogramObject();
HistogramObject(const QImage &image);
HistogramObject(const HistogramObject &hobj);
HistogramObject(QObject *parent = nullptr);
HistogramObject(const QImage &image, QObject *parent = nullptr);
HistogramObject(const HistogramObject &hobj, QObject *parent = nullptr);
~HistogramObject();
HistogramObject clone();
uint32_t operator[](int index);
int getIndex(int channel, int pixelIntensity);
int getNumChannels();
uint32_t getLargest();

public slots:
bool update(const QImage &image);
Expand Down
Loading

0 comments on commit 204e4af

Please sign in to comment.