28QString QgsFuzzifyRasterAlgorithmBase::group()
const
30 return QObject::tr(
"Raster analysis" );
33QString QgsFuzzifyRasterAlgorithmBase::groupId()
const
35 return QStringLiteral(
"rasteranalysis" );
38void QgsFuzzifyRasterAlgorithmBase::initAlgorithm(
const QVariantMap & )
41 addParameter(
new QgsProcessingParameterBand( QStringLiteral(
"BAND" ), QObject::tr(
"Band Number" ), 1, QStringLiteral(
"INPUT" ) ) );
57 mInputRaster = parameterAsRasterLayer( parameters, QStringLiteral(
"INPUT" ), context );
62 mBand = parameterAsInt( parameters, QStringLiteral(
"BAND" ), context );
63 if ( mBand < 1 || mBand > mInputRaster->bandCount() )
64 throw QgsProcessingException( QObject::tr(
"Invalid band number for BAND (%1): Valid values for input raster are 1 to %2" ).arg( mBand ).arg( mInputRaster->bandCount() ) );
66 mInterface.reset( mInputRaster->dataProvider()->clone() );
67 mExtent = mInputRaster->extent();
68 mLayerWidth = mInputRaster->width();
69 mLayerHeight = mInputRaster->height();
70 mCrs = mInputRaster->crs();
71 mNbCellsXProvider = mInterface->xSize();
72 mNbCellsYProvider = mInterface->ySize();
75 prepareAlgorithmFuzzificationParameters( parameters, context, feedback );
83 const QString outputFile = parameterAsOutputLayer( parameters, QStringLiteral(
"OUTPUT" ), context );
84 const QFileInfo fi( outputFile );
87 std::unique_ptr< QgsRasterFileWriter > writer = std::make_unique< QgsRasterFileWriter >( outputFile );
88 writer->setOutputProviderKey( QStringLiteral(
"gdal" ) );
89 writer->setOutputFormat( outputFormat );
90 std::unique_ptr<QgsRasterDataProvider > provider( writer->createOneBandRaster( mDataType, mNbCellsXProvider, mNbCellsYProvider, mExtent, mCrs ) );
93 if ( !provider->isValid() )
96 provider->setNoDataValue( 1, mNoDataValue );
97 provider->setEditable(
true );
98 const qgssize layerSize =
static_cast< qgssize >( mLayerWidth ) *
static_cast< qgssize >( mLayerHeight );
100 fuzzify( provider.get(), feedback );
102 provider->setEditable(
false );
105 outputs.insert( QStringLiteral(
"EXTENT" ), mExtent.toString() );
106 outputs.insert( QStringLiteral(
"CRS_AUTHID" ), mCrs.authid() );
107 outputs.insert( QStringLiteral(
"WIDTH_IN_PIXELS" ), mLayerWidth );
108 outputs.insert( QStringLiteral(
"HEIGHT_IN_PIXELS" ), mLayerHeight );
109 outputs.insert( QStringLiteral(
"TOTAL_PIXEL_COUNT" ), layerSize );
110 outputs.insert( QStringLiteral(
"OUTPUT" ), outputFile );
119QString QgsFuzzifyRasterLinearMembershipAlgorithm::name()
const
121 return QStringLiteral(
"fuzzifyrasterlinearmembership" );
124QString QgsFuzzifyRasterLinearMembershipAlgorithm::displayName()
const
126 return QObject::tr(
"Fuzzify raster (linear membership)" );
129QStringList QgsFuzzifyRasterLinearMembershipAlgorithm::tags()
const
131 return QObject::tr(
"fuzzy logic,fuzzify,fuzzy,logic,linear,membership" ).split(
',' );
135QString QgsFuzzifyRasterLinearMembershipAlgorithm::shortHelpString()
const
137 return QObject::tr(
"The Fuzzify raster (linear membership) algorithm transforms an input raster "
138 "to a fuzzified raster and thereby assigns values between 0 and 1 following a "
139 "linear fuzzy membership function. The value of 0 implies no membership with the "
140 "defined fuzzy set, a value of 1 depicts full membership. In between, the degree "
141 "of membership of raster values follows a linear membership function.\n\n"
142 "The linear function is constructed using two user-defined input raster values "
143 "which set the point of full membership (high bound, results to 1) and no membership "
144 "(low bound, results to 0) respectively. The fuzzy set in between those values is defined as a "
145 "linear function.\n\n"
146 "Both increasing and decreasing fuzzy sets can be modeled by "
147 "swapping the high and low bound parameters." );
150QgsFuzzifyRasterLinearMembershipAlgorithm *QgsFuzzifyRasterLinearMembershipAlgorithm::createInstance()
const
152 return new QgsFuzzifyRasterLinearMembershipAlgorithm();
155void QgsFuzzifyRasterLinearMembershipAlgorithm::addAlgorithmParams( )
164 mFuzzifyHighBound = parameterAsDouble( parameters, QStringLiteral(
"FUZZYHIGHBOUND" ), context );
165 mFuzzifyLowBound = parameterAsDouble( parameters, QStringLiteral(
"FUZZYLOWBOUND" ), context );
173 const int nbBlocksWidth =
static_cast< int >( std::ceil( 1.0 * mLayerWidth / maxWidth ) );
174 const int nbBlocksHeight =
static_cast< int >( std::ceil( 1.0 * mLayerHeight / maxHeight ) );
175 const int nbBlocks = nbBlocksWidth * nbBlocksHeight;
178 iter.startRasterRead( mBand, mLayerWidth, mLayerHeight, mExtent );
183 bool isNoData =
false;
184 std::unique_ptr< QgsRasterBlock > rasterBlock;
185 while ( iter.readNextRasterPart( mBand, iterCols, iterRows, rasterBlock, iterLeft, iterTop ) )
188 feedback->
setProgress( 100 * ( ( iterTop / maxHeight * nbBlocksWidth ) + iterLeft / maxWidth ) / nbBlocks );
189 std::unique_ptr< QgsRasterBlock > fuzzifiedBlock = std::make_unique< QgsRasterBlock >( destinationProvider->
dataType( 1 ), iterCols, iterRows );
191 for (
int row = 0; row < iterRows; row++ )
195 for (
int column = 0; column < iterCols; column++ )
200 const double value = rasterBlock->valueAndNoData( row, column, isNoData );
201 double fuzzifiedValue;
205 fuzzifiedValue = mNoDataValue;
207 else if ( mFuzzifyLowBound < mFuzzifyHighBound )
209 if ( value <= mFuzzifyLowBound )
211 else if ( value >= mFuzzifyHighBound )
214 fuzzifiedValue = ( ( value - mFuzzifyLowBound ) / ( mFuzzifyHighBound - mFuzzifyLowBound ) );
216 else if ( mFuzzifyLowBound > mFuzzifyHighBound )
218 if ( value >= mFuzzifyLowBound )
220 else if ( value <= mFuzzifyHighBound )
223 fuzzifiedValue = ( ( value - mFuzzifyLowBound ) / ( mFuzzifyHighBound - mFuzzifyLowBound ) );
227 throw QgsProcessingException( QObject::tr(
"Please choose varying values for the high and low membership parameters" ) );
230 fuzzifiedBlock->setValue( row, column, fuzzifiedValue );
233 destinationProvider->
writeBlock( fuzzifiedBlock.get(), mBand, iterLeft, iterTop );
242QString QgsFuzzifyRasterPowerMembershipAlgorithm::name()
const
244 return QStringLiteral(
"fuzzifyrasterpowermembership" );
247QString QgsFuzzifyRasterPowerMembershipAlgorithm::displayName()
const
249 return QObject::tr(
"Fuzzify raster (power membership)" );
252QStringList QgsFuzzifyRasterPowerMembershipAlgorithm::tags()
const
254 return QObject::tr(
"fuzzy logic,fuzzify,fuzzy,logic,power,non-linear,membership,exponent" ).split(
',' );
258QString QgsFuzzifyRasterPowerMembershipAlgorithm::shortHelpString()
const
260 return QObject::tr(
"The Fuzzify raster (power membership) algorithm transforms an input raster "
261 "to a fuzzified raster and thereby assigns values between 0 and 1 following a "
262 "power function. The value of 0 implies no membership with the "
263 "defined fuzzy set, a value of 1 depicts full membership. In between, the degree "
264 "of membership of raster values follows a power function.\n\n"
265 "The power function is constructed using three user-defined input raster values "
266 "which set the point of full membership (high bound, results to 1), no membership "
267 "(low bound, results to 0) and function exponent (only positive) respectively. "
268 "The fuzzy set in between those the upper and lower bounds values is then defined as "
269 "a power function.\n\n"
270 "Both increasing and decreasing fuzzy sets can be modeled by "
271 "swapping the high and low bound parameters." );
274QgsFuzzifyRasterPowerMembershipAlgorithm *QgsFuzzifyRasterPowerMembershipAlgorithm::createInstance()
const
276 return new QgsFuzzifyRasterPowerMembershipAlgorithm();
279void QgsFuzzifyRasterPowerMembershipAlgorithm::addAlgorithmParams( )
289 mFuzzifyHighBound = parameterAsDouble( parameters, QStringLiteral(
"FUZZYHIGHBOUND" ), context );
290 mFuzzifyLowBound = parameterAsDouble( parameters, QStringLiteral(
"FUZZYLOWBOUND" ), context );
291 mFuzzifyExponent = parameterAsDouble( parameters, QStringLiteral(
"FUZZYEXPONENT" ), context );
299 const int nbBlocksWidth =
static_cast< int >( std::ceil( 1.0 * mLayerWidth / maxWidth ) );
300 const int nbBlocksHeight =
static_cast< int >( std::ceil( 1.0 * mLayerHeight / maxHeight ) );
301 const int nbBlocks = nbBlocksWidth * nbBlocksHeight;
304 iter.startRasterRead( mBand, mLayerWidth, mLayerHeight, mExtent );
309 bool isNoData =
false;
310 std::unique_ptr< QgsRasterBlock > rasterBlock;
311 while ( iter.readNextRasterPart( mBand, iterCols, iterRows, rasterBlock, iterLeft, iterTop ) )
314 feedback->
setProgress( 100 * ( ( iterTop / maxHeight * nbBlocksWidth ) + iterLeft / maxWidth ) / nbBlocks );
315 std::unique_ptr< QgsRasterBlock > fuzzifiedBlock = std::make_unique< QgsRasterBlock >( destinationProvider->
dataType( 1 ), iterCols, iterRows );
317 for (
int row = 0; row < iterRows; row++ )
321 for (
int column = 0; column < iterCols; column++ )
326 const double value = rasterBlock->valueAndNoData( row, column, isNoData );
327 double fuzzifiedValue;
331 fuzzifiedValue = mNoDataValue;
333 else if ( mFuzzifyLowBound < mFuzzifyHighBound )
335 if ( value <= mFuzzifyLowBound )
337 else if ( value >= mFuzzifyHighBound )
340 fuzzifiedValue = std::pow( ( value - mFuzzifyLowBound ) / ( mFuzzifyHighBound - mFuzzifyLowBound ), mFuzzifyExponent );
342 else if ( mFuzzifyLowBound > mFuzzifyHighBound )
344 if ( value >= mFuzzifyLowBound )
346 else if ( value <= mFuzzifyHighBound )
349 fuzzifiedValue = std::pow( ( value - mFuzzifyLowBound ) / ( mFuzzifyHighBound - mFuzzifyLowBound ), mFuzzifyExponent );
353 throw QgsProcessingException( QObject::tr(
"Please choose varying values for the high and low membership parameters" ) );
356 fuzzifiedBlock->setValue( row, column, fuzzifiedValue );
359 destinationProvider->
writeBlock( fuzzifiedBlock.get(), mBand, iterLeft, iterTop );
367QString QgsFuzzifyRasterLargeMembershipAlgorithm::name()
const
369 return QStringLiteral(
"fuzzifyrasterlargemembership" );
372QString QgsFuzzifyRasterLargeMembershipAlgorithm::displayName()
const
374 return QObject::tr(
"Fuzzify raster (large membership)" );
377QStringList QgsFuzzifyRasterLargeMembershipAlgorithm::tags()
const
379 return QObject::tr(
"fuzzy logic,fuzzify,fuzzy,logic,large,membership" ).split(
',' );
383QString QgsFuzzifyRasterLargeMembershipAlgorithm::shortHelpString()
const
385 return QObject::tr(
"The Fuzzify raster (large membership) algorithm transforms an input raster "
386 "to a fuzzified raster and thereby assigns values between 0 and 1 following the "
387 "'large' fuzzy membership function. The value of 0 implies no membership with the "
388 "defined fuzzy set, a value of 1 depicts full membership. In between, the degree "
389 "of membership of raster values follows the 'large' membership function.\n\n"
390 "The 'large' function is constructed using two user-defined input raster values "
391 "which set the point of half membership (midpoint, results to 0.5) and a predefined "
392 "function spread which controls the function uptake.\n\n"
393 "This function is typically used when larger input raster values should become members "
394 "of the fuzzy set more easily than smaller values." );
397QgsFuzzifyRasterLargeMembershipAlgorithm *QgsFuzzifyRasterLargeMembershipAlgorithm::createInstance()
const
399 return new QgsFuzzifyRasterLargeMembershipAlgorithm();
402void QgsFuzzifyRasterLargeMembershipAlgorithm::addAlgorithmParams( )
411 mFuzzifyMidpoint = parameterAsDouble( parameters, QStringLiteral(
"FUZZYMIDPOINT" ), context );
412 mFuzzifySpread = parameterAsDouble( parameters, QStringLiteral(
"FUZZYSPREAD" ), context );
420 const int nbBlocksWidth =
static_cast< int >( std::ceil( 1.0 * mLayerWidth / maxWidth ) );
421 const int nbBlocksHeight =
static_cast< int >( std::ceil( 1.0 * mLayerHeight / maxHeight ) );
422 const int nbBlocks = nbBlocksWidth * nbBlocksHeight;
425 iter.startRasterRead( mBand, mLayerWidth, mLayerHeight, mExtent );
430 bool isNoData =
false;
431 std::unique_ptr< QgsRasterBlock > rasterBlock;
432 while ( iter.readNextRasterPart( mBand, iterCols, iterRows, rasterBlock, iterLeft, iterTop ) )
435 feedback->
setProgress( 100 * ( ( iterTop / maxHeight * nbBlocksWidth ) + iterLeft / maxWidth ) / nbBlocks );
436 std::unique_ptr< QgsRasterBlock > fuzzifiedBlock = std::make_unique< QgsRasterBlock >( destinationProvider->
dataType( 1 ), iterCols, iterRows );
438 for (
int row = 0; row < iterRows; row++ )
442 for (
int column = 0; column < iterCols; column++ )
447 const double value = rasterBlock->valueAndNoData( row, column, isNoData );
448 double fuzzifiedValue;
452 fuzzifiedValue = mNoDataValue;
456 fuzzifiedValue = 1 / ( 1 + std::pow( value / mFuzzifyMidpoint, -mFuzzifySpread ) );
459 fuzzifiedBlock->setValue( row, column, fuzzifiedValue );
462 destinationProvider->
writeBlock( fuzzifiedBlock.get(), mBand, iterLeft, iterTop );
471QString QgsFuzzifyRasterSmallMembershipAlgorithm::name()
const
473 return QStringLiteral(
"fuzzifyrastersmallmembership" );
476QString QgsFuzzifyRasterSmallMembershipAlgorithm::displayName()
const
478 return QObject::tr(
"Fuzzify raster (small membership)" );
481QStringList QgsFuzzifyRasterSmallMembershipAlgorithm::tags()
const
483 return QObject::tr(
"fuzzy logic,fuzzify,fuzzy,logic,small,membership" ).split(
',' );
487QString QgsFuzzifyRasterSmallMembershipAlgorithm::shortHelpString()
const
489 return QObject::tr(
"The Fuzzify raster (small membership) algorithm transforms an input raster "
490 "to a fuzzified raster and thereby assigns values between 0 and 1 following the "
491 "'small' fuzzy membership function. The value of 0 implies no membership with the "
492 "defined fuzzy set, a value of 1 depicts full membership. In between, the degree "
493 "of membership of raster values follows the 'small' membership function.\n\n"
494 "The 'small' function is constructed using two user-defined input raster values "
495 "which set the point of half membership (midpoint, results to 0.5) and a predefined "
496 "function spread which controls the function uptake.\n\n"
497 "This function is typically used when smaller input raster values should become members "
498 "of the fuzzy set more easily than higher values." );
501QgsFuzzifyRasterSmallMembershipAlgorithm *QgsFuzzifyRasterSmallMembershipAlgorithm::createInstance()
const
503 return new QgsFuzzifyRasterSmallMembershipAlgorithm();
506void QgsFuzzifyRasterSmallMembershipAlgorithm::addAlgorithmParams( )
515 mFuzzifyMidpoint = parameterAsDouble( parameters, QStringLiteral(
"FUZZYMIDPOINT" ), context );
516 mFuzzifySpread = parameterAsDouble( parameters, QStringLiteral(
"FUZZYSPREAD" ), context );
524 const int nbBlocksWidth =
static_cast< int >( std::ceil( 1.0 * mLayerWidth / maxWidth ) );
525 const int nbBlocksHeight =
static_cast< int >( std::ceil( 1.0 * mLayerHeight / maxHeight ) );
526 const int nbBlocks = nbBlocksWidth * nbBlocksHeight;
529 iter.startRasterRead( mBand, mLayerWidth, mLayerHeight, mExtent );
534 bool isNoData =
false;
535 std::unique_ptr< QgsRasterBlock > rasterBlock;
536 while ( iter.readNextRasterPart( mBand, iterCols, iterRows, rasterBlock, iterLeft, iterTop ) )
539 feedback->
setProgress( 100 * ( ( iterTop / maxHeight * nbBlocksWidth ) + iterLeft / maxWidth ) / nbBlocks );
540 std::unique_ptr< QgsRasterBlock > fuzzifiedBlock = std::make_unique< QgsRasterBlock >( destinationProvider->
dataType( 1 ), iterCols, iterRows );
542 for (
int row = 0; row < iterRows; row++ )
546 for (
int column = 0; column < iterCols; column++ )
551 const double value = rasterBlock->valueAndNoData( row, column, isNoData );
552 double fuzzifiedValue;
556 fuzzifiedValue = mNoDataValue;
560 fuzzifiedValue = 1 / ( 1 + std::pow( value / mFuzzifyMidpoint, mFuzzifySpread ) );
563 fuzzifiedBlock->setValue( row, column, fuzzifiedValue );
566 destinationProvider->
writeBlock( fuzzifiedBlock.get(), mBand, iterLeft, iterTop );
575QString QgsFuzzifyRasterGaussianMembershipAlgorithm::name()
const
577 return QStringLiteral(
"fuzzifyrastergaussianmembership" );
580QString QgsFuzzifyRasterGaussianMembershipAlgorithm::displayName()
const
582 return QObject::tr(
"Fuzzify raster (gaussian membership)" );
585QStringList QgsFuzzifyRasterGaussianMembershipAlgorithm::tags()
const
587 return QObject::tr(
"fuzzy logic,fuzzify,fuzzy,logic,gaussian,membership" ).split(
',' );
591QString QgsFuzzifyRasterGaussianMembershipAlgorithm::shortHelpString()
const
593 return QObject::tr(
"The Fuzzify raster (gaussian membership) algorithm transforms an input raster "
594 "to a fuzzified raster and thereby assigns values between 0 and 1 following a "
595 "gaussian fuzzy membership function. The value of 0 implies no membership with the "
596 "defined fuzzy set, a value of 1 depicts full membership. In between, the degree "
597 "of membership of raster values follows a gaussian membership function.\n\n"
598 "The gaussian function is constructed using two user-defined input values "
599 "which set the midpoint of the gaussian function (midpoint, results to 1) and a "
600 "predefined function spread which controls the function spread.\n\n"
601 "This function is typically used when a certain range of raster values around a "
602 "predefined function midpoint should become members of the fuzzy set." );
605QgsFuzzifyRasterGaussianMembershipAlgorithm *QgsFuzzifyRasterGaussianMembershipAlgorithm::createInstance()
const
607 return new QgsFuzzifyRasterGaussianMembershipAlgorithm();
610void QgsFuzzifyRasterGaussianMembershipAlgorithm::addAlgorithmParams( )
619 mFuzzifyMidpoint = parameterAsDouble( parameters, QStringLiteral(
"FUZZYMIDPOINT" ), context );
620 mFuzzifySpread = parameterAsDouble( parameters, QStringLiteral(
"FUZZYSPREAD" ), context );
628 const int nbBlocksWidth =
static_cast< int >( std::ceil( 1.0 * mLayerWidth / maxWidth ) );
629 const int nbBlocksHeight =
static_cast< int >( std::ceil( 1.0 * mLayerHeight / maxHeight ) );
630 const int nbBlocks = nbBlocksWidth * nbBlocksHeight;
633 iter.startRasterRead( mBand, mLayerWidth, mLayerHeight, mExtent );
638 bool isNoData =
false;
639 std::unique_ptr< QgsRasterBlock > rasterBlock;
640 while ( iter.readNextRasterPart( mBand, iterCols, iterRows, rasterBlock, iterLeft, iterTop ) )
643 feedback->
setProgress( 100 * ( ( iterTop / maxHeight * nbBlocksWidth ) + iterLeft / maxWidth ) / nbBlocks );
644 std::unique_ptr< QgsRasterBlock > fuzzifiedBlock = std::make_unique< QgsRasterBlock >( destinationProvider->
dataType( 1 ), iterCols, iterRows );
646 for (
int row = 0; row < iterRows; row++ )
650 for (
int column = 0; column < iterCols; column++ )
655 const double value = rasterBlock->valueAndNoData( row, column, isNoData );
656 double fuzzifiedValue;
660 fuzzifiedValue = mNoDataValue;
664 fuzzifiedValue = std::exp( -mFuzzifySpread * std::pow( value - mFuzzifyMidpoint, 2 ) );
667 fuzzifiedBlock->setValue( row, column, fuzzifiedValue );
670 destinationProvider->
writeBlock( fuzzifiedBlock.get(), mBand, iterLeft, iterTop );
679QString QgsFuzzifyRasterNearMembershipAlgorithm::name()
const
681 return QStringLiteral(
"fuzzifyrasternearmembership" );
684QString QgsFuzzifyRasterNearMembershipAlgorithm::displayName()
const
686 return QObject::tr(
"Fuzzify raster (near membership)" );
689QStringList QgsFuzzifyRasterNearMembershipAlgorithm::tags()
const
691 return QObject::tr(
"fuzzy logic,fuzzify,fuzzy,logic,near,membership" ).split(
',' );
695QString QgsFuzzifyRasterNearMembershipAlgorithm::shortHelpString()
const
697 return QObject::tr(
"The Fuzzify raster (near membership) algorithm transforms an input raster "
698 "to a fuzzified raster and thereby assigns values between 0 and 1 following the "
699 "'near' fuzzy membership function. The value of 0 implies no membership with the "
700 "defined fuzzy set, a value of 1 depicts full membership. In between, the degree "
701 "of membership of raster values follows the 'near' membership function.\n\n"
702 "The 'near' function is constructed using two user-defined input values "
703 "which set the midpoint of the 'near' function (midpoint, results to 1) and a "
704 "predefined function spread which controls the function spread.\n\n"
705 "This function is typically used when a certain range of raster values near a "
706 "predefined function midpoint should become members of the fuzzy set. The function"
707 " generally shows a higher rate of decay than the gaussian membership function." );
710QgsFuzzifyRasterNearMembershipAlgorithm *QgsFuzzifyRasterNearMembershipAlgorithm::createInstance()
const
712 return new QgsFuzzifyRasterNearMembershipAlgorithm();
715void QgsFuzzifyRasterNearMembershipAlgorithm::addAlgorithmParams( )
724 mFuzzifyMidpoint = parameterAsDouble( parameters, QStringLiteral(
"FUZZYMIDPOINT" ), context );
725 mFuzzifySpread = parameterAsDouble( parameters, QStringLiteral(
"FUZZYSPREAD" ), context );
733 const int nbBlocksWidth =
static_cast< int >( std::ceil( 1.0 * mLayerWidth / maxWidth ) );
734 const int nbBlocksHeight =
static_cast< int >( std::ceil( 1.0 * mLayerHeight / maxHeight ) );
735 const int nbBlocks = nbBlocksWidth * nbBlocksHeight;
738 iter.startRasterRead( mBand, mLayerWidth, mLayerHeight, mExtent );
743 bool isNoData =
false;
744 std::unique_ptr< QgsRasterBlock > rasterBlock;
745 while ( iter.readNextRasterPart( mBand, iterCols, iterRows, rasterBlock, iterLeft, iterTop ) )
748 feedback->
setProgress( 100 * ( ( iterTop / maxHeight * nbBlocksWidth ) + iterLeft / maxWidth ) / nbBlocks );
749 std::unique_ptr< QgsRasterBlock > fuzzifiedBlock = std::make_unique< QgsRasterBlock >( destinationProvider->
dataType( 1 ), iterCols, iterRows );
751 for (
int row = 0; row < iterRows; row++ )
755 for (
int column = 0; column < iterCols; column++ )
760 const double value = rasterBlock->valueAndNoData( row, column, isNoData );
761 double fuzzifiedValue;
765 fuzzifiedValue = mNoDataValue;
769 fuzzifiedValue = 1 / ( 1 + mFuzzifySpread * std::pow( value - mFuzzifyMidpoint, 2 ) );
772 fuzzifiedBlock->setValue( row, column, fuzzifiedValue );
775 destinationProvider->
writeBlock( fuzzifiedBlock.get(), mBand, iterLeft, iterTop );
bool isCanceled() const
Tells whether the operation has been canceled already.
void setProgress(double progress)
Sets the current progress for the feedback object.
Contains information about the context in which a processing algorithm is executed.
Custom exception class for processing related exceptions.
Base class for providing feedback from a processing algorithm.
A numeric output for processing algorithms.
A string output for processing algorithms.
A raster band parameter for Processing algorithms.
A numeric parameter for processing algorithms.
@ Double
Double/float values.
A raster layer destination parameter, for specifying the destination path for a raster layer created ...
A raster layer parameter for processing algorithms.
Base class for raster data providers.
bool writeBlock(QgsRasterBlock *block, int band, int xOffset=0, int yOffset=0)
Writes pixel data from a raster block into the provider data source.
Qgis::DataType dataType(int bandNo) const override=0
Returns data type for the band specified by number.
static QString driverForExtension(const QString &extension)
Returns the GDAL driver name for a specified file extension.
Iterator for sequentially processing raster cells.
static const int DEFAULT_MAXIMUM_TILE_WIDTH
Default maximum tile width.
static const int DEFAULT_MAXIMUM_TILE_HEIGHT
Default maximum tile height.
unsigned long long qgssize
Qgssize is used instead of size_t, because size_t is stdlib type, unknown by SIP, and it would be har...