|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "stdfx.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tfxparam.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tpixelutils.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tparamset.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class RGBMCutFx : public TStandardRasterFx
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
FX_PLUGIN_DECLARATION(RGBMCutFx)
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TRasterFxPort m_input;
|
|
Toshihiro Shimizu |
890ddd |
TRangeParamP m_r_range;
|
|
Toshihiro Shimizu |
890ddd |
TRangeParamP m_g_range;
|
|
Toshihiro Shimizu |
890ddd |
TRangeParamP m_b_range;
|
|
Toshihiro Shimizu |
890ddd |
TRangeParamP m_m_range;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
RGBMCutFx()
|
|
Toshihiro Shimizu |
890ddd |
: m_r_range(DoublePair(0., 255.)), m_g_range(DoublePair(0., 255.)), m_b_range(DoublePair(0., 255.)), m_m_range(DoublePair(0., 255.))
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "r_range", m_r_range);
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "g_range", m_g_range);
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "b_range", m_b_range);
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "m_range", m_m_range);
|
|
Toshihiro Shimizu |
890ddd |
m_r_range->getMin()->setValueRange(0., 255.);
|
|
Toshihiro Shimizu |
890ddd |
m_g_range->getMin()->setValueRange(0., 255.);
|
|
Toshihiro Shimizu |
890ddd |
m_b_range->getMin()->setValueRange(0., 255.);
|
|
Toshihiro Shimizu |
890ddd |
m_m_range->getMin()->setValueRange(0., 255.);
|
|
Toshihiro Shimizu |
890ddd |
m_r_range->getMax()->setValueRange(0., 255.);
|
|
Toshihiro Shimizu |
890ddd |
m_g_range->getMax()->setValueRange(0., 255.);
|
|
Toshihiro Shimizu |
890ddd |
m_b_range->getMax()->setValueRange(0., 255.);
|
|
Toshihiro Shimizu |
890ddd |
m_m_range->getMax()->setValueRange(0., 255.);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
addInputPort("Source", m_input);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
~RGBMCutFx(){};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool doGetBBox(double frame, TRectD &bBox, const TRenderSettings &info)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return m_input.getFx() && m_input->doGetBBox(frame, bBox, info);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void doCompute(TTile &tile, double frame, const TRenderSettings &);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool canHandle(const TRenderSettings &info, double frame) { return true; }
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
namespace
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
void update_param(double ¶m, TRaster32P ras)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void update_param(double ¶m, TRaster64P ras)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
param = param * 257;
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <typename channel_type="" pixel,="" typename=""></typename>
|
|
Toshihiro Shimizu |
890ddd |
void doRGBMCut(TRasterPT<pixel> ras, double hi_m, double hi_r, double hi_g, double hi_b,</pixel>
|
|
Toshihiro Shimizu |
890ddd |
double lo_m, double lo_r, double lo_g, double lo_b)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
update_param(hi_m, ras);
|
|
Toshihiro Shimizu |
890ddd |
update_param(hi_r, ras);
|
|
Toshihiro Shimizu |
890ddd |
update_param(hi_g, ras);
|
|
Toshihiro Shimizu |
890ddd |
update_param(hi_b, ras);
|
|
Toshihiro Shimizu |
890ddd |
update_param(lo_m, ras);
|
|
Toshihiro Shimizu |
890ddd |
update_param(lo_r, ras);
|
|
Toshihiro Shimizu |
890ddd |
update_param(lo_g, ras);
|
|
Toshihiro Shimizu |
890ddd |
update_param(lo_b, ras);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int j;
|
|
Toshihiro Shimizu |
890ddd |
ras->lock();
|
|
Toshihiro Shimizu |
890ddd |
for (j = 0; j < ras->getLy(); j++) {
|
|
Toshihiro Shimizu |
890ddd |
PIXEL *pix = ras->pixels(j);
|
|
Toshihiro Shimizu |
890ddd |
PIXEL *endPix = pix + ras->getLx();
|
|
Toshihiro Shimizu |
890ddd |
while (pix < endPix) {
|
|
Toshihiro Shimizu |
890ddd |
if (pix->m != 0) {
|
|
Toshihiro Shimizu |
890ddd |
*pix = depremultiply(*pix);
|
|
Toshihiro Shimizu |
890ddd |
if (lo_m == 0)
|
|
Toshihiro Shimizu |
890ddd |
pix->m = tcrop((int)pix->m, (int)lo_m, (int)hi_m);
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
pix->m = (pix->m) ? tcrop((int)pix->m, (int)lo_m, (int)hi_m) : 0;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
pix->r = tcrop((int)pix->r, (int)lo_r, (int)hi_r);
|
|
Toshihiro Shimizu |
890ddd |
pix->g = tcrop((int)pix->g, (int)lo_g, (int)hi_g);
|
|
Toshihiro Shimizu |
890ddd |
pix->b = tcrop((int)pix->b, (int)lo_b, (int)hi_b);
|
|
Toshihiro Shimizu |
890ddd |
*pix = premultiply(*pix);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
*pix++;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
ras->unlock();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void RGBMCutFx::doCompute(TTile &tile, double frame, const TRenderSettings &ri)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (!m_input.isConnected())
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_input->compute(tile, frame, ri);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
double hi_m = m_m_range->getMax()->getValue(frame);
|
|
Toshihiro Shimizu |
890ddd |
double hi_r = m_r_range->getMax()->getValue(frame);
|
|
Toshihiro Shimizu |
890ddd |
double hi_g = m_g_range->getMax()->getValue(frame);
|
|
Toshihiro Shimizu |
890ddd |
double hi_b = m_b_range->getMax()->getValue(frame);
|
|
Toshihiro Shimizu |
890ddd |
double lo_m = m_m_range->getMin()->getValue(frame);
|
|
Toshihiro Shimizu |
890ddd |
double lo_r = m_r_range->getMin()->getValue(frame);
|
|
Toshihiro Shimizu |
890ddd |
double lo_g = m_g_range->getMin()->getValue(frame);
|
|
Toshihiro Shimizu |
890ddd |
double lo_b = m_b_range->getMin()->getValue(frame);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TRaster32P raster32 = tile.getRaster();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (raster32)
|
|
Toshihiro Shimizu |
890ddd |
doRGBMCut<tpixel32, uchar="">(raster32, hi_m, hi_r, hi_g, hi_b, lo_m, lo_r, lo_g, lo_b);</tpixel32,>
|
|
Toshihiro Shimizu |
890ddd |
else {
|
|
Toshihiro Shimizu |
890ddd |
TRaster64P raster64 = tile.getRaster();
|
|
Toshihiro Shimizu |
890ddd |
if (raster64)
|
|
Toshihiro Shimizu |
890ddd |
doRGBMCut<tpixel64, ushort="">(raster64, hi_m, hi_r, hi_g, hi_b, lo_m, lo_r, lo_g, lo_b);</tpixel64,>
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
throw TException("RGBMCutFx: unsupported Pixel Type");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
FX_PLUGIN_IDENTIFIER(RGBMCutFx, "rgbmCutFx")
|