2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
|
|
|
|
// TnzCore includes
|
|
|
|
#include "trop.h"
|
|
|
|
|
|
|
|
// TnzBase includes
|
|
|
|
#include "tfxparam.h"
|
|
|
|
|
|
|
|
// TnzStdfx includes
|
|
|
|
#include "stdfx.h"
|
|
|
|
|
2021-09-02 20:36:37 +12:00
|
|
|
#include "globalcontrollablefx.h"
|
|
|
|
|
2016-03-19 06:57:51 +13:00
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
|
2021-09-02 20:36:37 +12:00
|
|
|
class DespeckleFx final : public GlobalControllableFx {
|
2016-06-15 18:43:10 +12:00
|
|
|
FX_PLUGIN_DECLARATION(DespeckleFx)
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
TRasterFxPort m_input;
|
|
|
|
TIntParamP m_size;
|
|
|
|
TIntEnumParamP m_transparenceType;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
public:
|
2016-06-15 18:43:10 +12:00
|
|
|
DespeckleFx()
|
|
|
|
: m_size(1), m_transparenceType(new TIntEnumParam(0, "Transparent Bg")) {
|
|
|
|
bindParam(this, "size", m_size);
|
|
|
|
bindParam(this, "detect_speckles_on", m_transparenceType);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
m_transparenceType->addItem(1, "White Bg");
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
addInputPort("Source", m_input);
|
|
|
|
m_size->setValueRange(1, 1000);
|
|
|
|
}
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-20 14:23:05 +12:00
|
|
|
bool doGetBBox(double frame, TRectD &bBox,
|
|
|
|
const TRenderSettings &info) override;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-19 20:06:29 +12:00
|
|
|
void doCompute(TTile &tile, double frame, const TRenderSettings &) override;
|
2016-06-20 14:23:05 +12:00
|
|
|
void doDryCompute(TRectD &rect, double frame,
|
|
|
|
const TRenderSettings &info) override;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-20 14:23:05 +12:00
|
|
|
bool canHandle(const TRenderSettings &info, double frame) override {
|
|
|
|
return false;
|
|
|
|
}
|
2016-03-19 06:57:51 +13:00
|
|
|
};
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
bool DespeckleFx::doGetBBox(double frame, TRectD &bBox,
|
|
|
|
const TRenderSettings &info) {
|
|
|
|
if (m_input.isConnected())
|
|
|
|
return m_input->doGetBBox(frame, bBox, info);
|
|
|
|
else {
|
|
|
|
bBox = TRectD();
|
|
|
|
return false;
|
|
|
|
}
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void DespeckleFx::doCompute(TTile &tile, double frame,
|
|
|
|
const TRenderSettings &ri) {
|
|
|
|
if (!m_input.isConnected()) return;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
m_input->compute(tile, frame, ri);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
int size = m_size->getValue();
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
TRop::despeckle(tile.getRaster(), size, false,
|
|
|
|
m_transparenceType->getValue() == 1);
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void DespeckleFx::doDryCompute(TRectD &rect, double frame,
|
|
|
|
const TRenderSettings &info) {
|
|
|
|
if (!m_input.isConnected()) return;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
m_input->dryCompute(rect, frame, info);
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
|
|
|
|
FX_PLUGIN_IDENTIFIER(DespeckleFx, "despeckleFx")
|