16 #include <QMessageBox> 51 return( seedsVisible );
55 return( maskVisible );
60 COMMENT(
"thickness set to" << thickness, 2 );
64 guiImage->getDim( ) ) {
67 setObjectName(
"SegmentationTool" );
84 if( ( drawType == 1 ) || ( drawType == 2 ) ) {
102 if( lastPoint == current ) {
107 if( timer.elapsed( ) > 30 ) {
136 needUpdate[ axis ] =
true;
145 vLast = { { ( float ) last[ 0 ], (
float ) last[ 1 ], ( float ) last[ 2 ] } };
146 vCurrent = { { ( float ) current[ 0 ], (
float ) current[ 1 ], ( float ) current[ 2 ] } };
149 vLast = { { ( float ) last[ 0 ], (
float ) last[ 1 ] } };
150 vCurrent = { { ( float ) current[ 0 ], (
float ) current[ 1 ] } };
153 imgLine.
Draw( seeds );
156 for(
size_t px = 0; px <
size; px++ ) {
157 if( seeds[ px ] == 255 ) {
159 for( it.
begin( ); *it < seeds.
size( ); ++it ) {
160 seeds[ *it ] = drawType;
164 for(
size_t i = 0; i < needUpdate.size( ); ++i ) {
165 needUpdate[ i ] =
true;
174 for(
size_t i = 0; i < seeds.
Size( ); ++i ) {
177 for(
size_t i = 0; i < needUpdate.size( ); ++i ) {
178 needUpdate[ i ] =
true;
187 for(
size_t i = 0; i < seeds.
size( ); ++i ) {
188 if( seeds[ i ] == 1 ) {
191 else if( seeds[ i ] == 2 ) {
196 if( ( !obj_seed.
empty( ) ) && ( !bkg_seed.
empty( ) ) ) {
211 std::string msg(
BIAL_ERROR(
"Getting image from non initialized multi-image." ) );
212 throw( std::runtime_error( msg ) );
220 throw std::runtime_error(
"Seeds Missing" );
227 if( !seedsVisible && !maskVisible ) {
228 return( QPixmap( ) );
230 if( !needUpdate[ axis ] ) {
231 return( pixmaps[ axis ] );
234 QImage res( xsz, ysz, QImage::Format_ARGB32 );
235 if( !seedsVisible ) {
236 res.fill( qRgba( 0, 0, 0, 0 ) );
239 #pragma omp parallel for firstprivate(axis, xsz, ysz) 240 for(
size_t y = 0; y < ysz; ++y ) {
241 QRgb *scanLine = ( QRgb* ) res.scanLine( y );
242 for(
size_t x = 0; x < xsz; ++x ) {
244 char pixel = seeds( pos.
x, pos.
y, pos.
z );
246 scanLine[ x ] = qRgb( 0, 255, 0 );
248 else if( pixel == 2 ) {
249 scanLine[ x ] = qRgb( 0, 0, 255 );
252 scanLine[ x ] = qRgba( 0, 0, 0, 0 );
257 if( maskVisible && ( mask.
size( ) == seeds.
size( ) ) ) {
258 #pragma omp parallel for firstprivate(axis, xsz, ysz) 259 for(
size_t y = 0; y < ysz; ++y ) {
260 QRgb *scanLine = ( QRgb* ) res.scanLine( y );
261 for(
size_t x = 0; x < xsz; ++x ) {
263 if( mask( pos.
x, pos.
y, pos.
z ) ) {
264 scanLine[ x ] = qRgb( 255, 0, 0 );
269 pixmaps[ axis ] = QPixmap::fromImage( res );
270 return( pixmaps[ axis ] );
void begin()
Sets position to first valid index.
double z
Point position in z.
Image< D > Morphological(const Image< D > &image)
Computes the gradient image (dilation - erosion) using spherical adjacency relation of one pixel of r...
size_t Size() const
Returns the image size.
void push_back(const D &val)
Inserts element in the end of the vector.
#define BIAL_ERROR(exp)
Use BIAL_ERROR to compose runtime error messages. Note that ERROR generates a string, instead of a stream, because it is better to throw an exception, rather than exiting the program. This way, the exception may be threated by a higher level program, like an user IDE.
Image< D > OrientedGeodesicStar(const Image< D > &image, const Vector< size_t > &obj_seeds, const Vector< size_t > &bkg_seeds, double alpha=0.0, double beta=0.5)
Returns the label from oriented geodesic segmentation algorithm. Use positive alpha values for light ...
Bial::MultiImageType getImageType() const
getImageType returns image type among int, float, Color and RealColor.
The GuiImage class is a bridge to the Bial::Image data structure to the QImage data structure...
size_t heigth(size_t view)
heigth is the view heigth.
The Point3D class is a Geometric representation of a point in 3D space. A point is a zerodimension...
double y
Point position in y.
size_t width(size_t view)
width is the view width.
Bial::FastTransform getTransform(size_t axis)
getTransform returns the transform matrix of the views.
Adjacency HyperSpheric(float radius=1.0, size_t dims=4)
Create and return a hyper-spheric adjacency relation of radius 'radius' and with dim dimensions...
void imageUpdated()
imageUpdated is called each time a internal property is updated, after that the image views are updat...
Bial::Image< int > & getIntImage() const
get*Image
void Draw(Image< D > &img) const
Draws 2D or 3D line in input image.
size_t size() const
Returns the image size. Same as Size( ), just for compatibility with std containers.
bool empty() const noexcept
Tests if vector is empty.
size_t currentSlice(size_t view)
currentSlice is the view's current slice.
Adjacency relation and forward iteratior related to a matrix.
Bial::Image< Bial::Color > & getClrImage() const
Bial::Image< float > & getFltImage() const
Bial::Image< Bial::RealColor > & getRclImage() const
size_t getDims() const
getDims