Commit 1ca04c3f authored by Kuntal  Majumder's avatar Kuntal Majumder 😟

Fixed the intensity function

Ref T10894
parent a6ee0565
......@@ -21,6 +21,7 @@
#include <boost/operators.hpp>
#include <boost/graph/graph_traits.hpp>
#include <kis_paint_device.h>
#include <kis_random_accessor_ng.h>
#include <QDebug>
#include <QRect>
......@@ -90,11 +91,10 @@ struct KisMagneticGraph{
QPoint topLeft, bottomRight;
double getIntensity(VertexDescriptor pt){
QColor *col = new QColor;
m_dev->pixel(pt.x, pt.y, col);
double intensity = col->blackF();
delete col;
return intensity;
KisRandomAccessorSP randAccess = m_dev->createRandomAccessorNG(m_dev->exactBounds().x(),m_dev->exactBounds().y());
randAccess->moveTo(pt.x, pt.y);
qint8 val = *(randAccess->rawData());
return std::abs(val);
}
private:
......
......@@ -101,7 +101,6 @@ class AStarHeuristic : public boost::astar_heuristic<KisMagneticGraph, double> {
double dz = EuclideanDistance(prev, m_goal);
di = di/dz;
double dm = EuclideanDistance(v, m_goal);
qDebug() << v << prev;
return coeff_a * di + coeff_b * (dm - dz) ;
}
};
......@@ -179,7 +178,7 @@ QRect KisMagneticWorker::calculateRect(QPoint p1, QPoint p2, int radius) const {
QVector<QPointF> KisMagneticWorker::computeEdge(KisPaintDeviceSP dev, int radius, QPoint begin, QPoint end) {
QRect rect = calculateRect(begin, end, radius);
KisGaussianKernel::applyLoG(dev, rect, 2, -1.0, QBitArray(), 0);
KisGaussianKernel::applyLoG(dev, rect, 2, -10.0, QBitArray(), 0);
VertexDescriptor goal(end);
VertexDescriptor start(begin);
......@@ -219,9 +218,5 @@ QVector<QPointF> KisMagneticWorker::computeEdge(KisPaintDeviceSP dev, int radius
result.push_back(QPoint(start.x,start.y));
for(auto val: result){
qDebug() << val;
}
return result;
}
......@@ -46,24 +46,24 @@ void KisMagneticWorkerTest::testWorker()
KisMagneticWorker worker;
KIS_DUMP_DEVICE_2(dev, rect, "main", "dd");
const QPointF startPos(30, 10);
const QPointF endPos(50, 65);
const QPoint startPos(40, 10);
const QPoint endPos(50, 65);
auto points = worker.computeEdge(grayscaleDev, 10, QPoint(30,10), QPoint(50,65));
auto points = worker.computeEdge(grayscaleDev, 10, startPos, endPos);
KIS_DUMP_DEVICE_2(grayscaleDev, rect, "draw", "dd");
QImage img = grayscaleDev->convertToQImage(0, rect);
img = img.convertToFormat(QImage::Format_ARGB32);
QPainter gc(&img);
QPainterPath path;
path.moveTo(points[0]);
QPainterPath path(points[0]);
for (int i = 1; i < points.size(); i++) {
path.lineTo(points[i]);
qDebug() << points[i];
}
gc.setPen(Qt::white);
gc.setPen(Qt::blue);
gc.drawPath(path);
gc.setPen(Qt::green);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment