artisteacher fd1c1e
#pragma once
shun-iwasawa e2505a
shun-iwasawa e2505a
/*------------------------------------
shun-iwasawa e2505a
Iwa_BokehRefFx
shun-iwasawa e2505a
Apply an off-focus effect to a single source image.
shun-iwasawa e2505a
The amount of bokeh is specified by user input reference image,
shun-iwasawa e2505a
which represents the depth by brightness of pixels.
shun-iwasawa e2505a
It considers characteristics of films (which is known as Hurter–Driffield
shun-iwasawa e2505a
curves) or human eye's perception (which is known as Weber–Fechner law).
shun-iwasawa e2505a
For filtering process I used KissFFT, an FFT library by Mark Borgerding,
shun-iwasawa e2505a
distributed with a 3-clause BSD-style license.
shun-iwasawa e2505a
------------------------------------*/
shun-iwasawa e2505a
shun-iwasawa e2505a
#ifndef IWA_BOKEH_REF_H
shun-iwasawa e2505a
#define IWA_BOKEH_REF_H
shun-iwasawa e2505a
shun-iwasawa e2505a
#include "stdfx.h"
shun-iwasawa e2505a
#include "tfxparam.h"
shun-iwasawa e2505a
shun-iwasawa e2505a
#include <qvector></qvector>
shun-iwasawa e2505a
#include <qthread></qthread>
shun-iwasawa e2505a
shun-iwasawa 1b1839
#include "iwa_bokeh_util.h"
shun-iwasawa e2505a
shun-iwasawa e2505a
//------------------------------------
shun-iwasawa e2505a
shun-iwasawa 1b1839
class Iwa_BokehRefFx : public Iwa_BokehCommonFx {
shun-iwasawa e2505a
  FX_PLUGIN_DECLARATION(Iwa_BokehRefFx)
shun-iwasawa e2505a
shun-iwasawa e2505a
protected:
shun-iwasawa e2505a
  TRasterFxPort m_source;  // source image
shun-iwasawa e2505a
  TRasterFxPort m_depth;   // depth reference image
shun-iwasawa e2505a
shun-iwasawa e2505a
  TIntParamP m_distancePrecision;  // Separation of depth image
shun-iwasawa e2505a
shun-iwasawa e2505a
  TBoolParamP m_fillGap;  // Toggles whether to extend pixels behind the front
shun-iwasawa e2505a
                          // layers in order to fill gap
shun-iwasawa e2505a
  // It should be ON for normal backgrounds and should be OFF for the layer
shun-iwasawa e2505a
  // which is
shun-iwasawa e2505a
  // "floating" from the lower layers such as dust, snowflake or spider-web.
shun-iwasawa e2505a
  TBoolParamP m_doMedian;  // (Effective only when the Fill Gap option is ON)
shun-iwasawa e2505a
  // Toggles whether to use Median Filter for extending the pixels.
shun-iwasawa e2505a
shun-iwasawa e2505a
  // normalize brightness of the depth reference image to unsigned char
shun-iwasawa e2505a
  // and store into dstMem
shun-iwasawa e2505a
  template <typename pixel="" raster,="" typename=""></typename>
shun-iwasawa e2505a
  void setDepthRaster(const RASTER srcRas, unsigned char* dstMem,
shun-iwasawa e2505a
                      TDimensionI dim);
shun-iwasawa e2505a
  template <typename pixel="" raster,="" typename=""></typename>
shun-iwasawa e2505a
  void setDepthRasterGray(const RASTER srcRas, unsigned char* dstMem,
shun-iwasawa e2505a
                          TDimensionI dim);
shun-iwasawa e2505a
shun-iwasawa e2505a
public:
shun-iwasawa e2505a
  Iwa_BokehRefFx();
shun-iwasawa e2505a
shun-iwasawa ce90c2
  void doCompute(TTile& tile, double frame,
shun-iwasawa ce90c2
                 const TRenderSettings& settings) override;
shun-iwasawa 481b59
shun-iwasawa 481b59
  void onFxVersionSet() final override;
shun-iwasawa e2505a
};
shun-iwasawa e2505a
shun-iwasawa e2505a
#endif