smistad / FAST

A framework for high-performance medical image processing, neural network inference and visualization
https://fast.eriksmistad.no
BSD 2-Clause "Simplified" License
433 stars 101 forks source link

GVF example error #148

Closed libaineu2004 closed 2 years ago

libaineu2004 commented 2 years ago

Describe the bug

My code is :

include "FAST/Importers/ImageFileImporter.hpp"

include "FAST/Visualization/ImageRenderer/ImageRenderer.hpp"

include "FAST/Visualization/SegmentationRenderer/SegmentationRenderer.hpp"

include "FAST/Visualization/SimpleWindow.hpp"

include "FAST/Algorithms/GradientVectorFlow/EulerGradientVectorFlow.hpp"

include "FAST/Algorithms/GradientVectorFlow/MultigridGradientVectorFlow.hpp"

using namespace fast;

int main() { auto importer = ImageFileImporter::create("d:\1.jpg"); auto gvf = MultigridGradientVectorFlow::create()->connect(importer); auto imageRenderer = ImageRenderer::create()->connect(importer); auto segmentationRenderer = SegmentationRenderer::create()->connect(gvf); auto window = SimpleWindow2D::create()->connect({ imageRenderer, segmentationRenderer });

ifdef FAST_CONTINUOUS_INTEGRATION

// This will automatically close the window after 5 seconds, used for CI testing
window->setTimeout(5 * 1000);

endif

window->run();
return 0;

}

The source code can be compiled, but it will run into errors!

To Reproduce The source code can be compiled, but it will run into errors.Run will throw an exception.

virtual bool notify(QObject receiver, QEvent event) { try { return QApplication::notify(receiver, event); } catch(Exception &e) { Reporter::error() << "FAST exception caught in Qt event handler " << e.what() << Reporter::end(); throw e;

System:

Expected behavior Can you give an example to correctly use EulerGradientVectorFlow and MultigridGradientVectorFlow?

Screenshots If applicable, add screenshots to help explain your problem. image

smistad commented 2 years ago

A couple of comments to your code:

Here is a working python example showing how GVF can be applied and visualized on a 2D grayscale image:

import fast

importer = fast.ImageFileImporter.create(fast.Config.getTestDataPath() + "retina.png")
gradient = fast.ImageGradient.create().connect(importer)
gvf = fast.EulerGradientVectorFlow.create().connect(gradient)

renderer = fast.ImageRenderer.create().connect(importer)
renderer2 = fast.VectorFieldColorRenderer.create().connect(gvf)
fast.SimpleWindow2D.create().connect([renderer, renderer2]).run()

Screenshot from 2021-09-13 10-57-33

For questions, please use the gitter chat instead: https://gitter.im/smistad/FAST

libaineu2004 commented 2 years ago

OK. I hope to add GVF usage examples to https://github.com/smistad/FAST/tree/master/source/FAST/Examples

libaineu2004 commented 2 years ago

How do I get the point coordinates of the contour processed by GVF?