20 #if !defined(__MITSUBA_RENDER_IMAGEBLOCK_H_)
21 #define __MITSUBA_RENDER_IMAGEBLOCK_H_
73 inline int getWidth()
const {
return m_size.x; }
79 inline bool getWarn()
const {
return m_warn; }
82 inline void setWarn(
bool warn) { m_warn = warn; }
100 inline void clear() { m_bitmap->clear(); }
125 Float temp[SPECTRUM_SAMPLES + 2];
126 for (
int i=0; i<SPECTRUM_SAMPLES; ++i)
128 temp[SPECTRUM_SAMPLES] = alpha;
129 temp[SPECTRUM_SAMPLES + 1] = 1.0f;
130 return put(pos, temp);
145 const int channels = m_bitmap->getChannelCount();
148 for (
int i=0; i<channels; ++i) {
149 if (EXPECT_NOT_TAKEN((!std::isfinite(value[i]) || value[i] < 0) && m_warn))
154 const Float filterRadius = m_filter->getRadius();
155 const Vector2i &size = m_bitmap->getSize();
159 _pos.x - 0.5f - (m_offset.x - m_borderSize),
160 _pos.y - 0.5f - (m_offset.y - m_borderSize));
163 const Point2i min(std::max((
int) std::ceil (pos.x - filterRadius), 0),
164 std::max((
int) std::ceil (pos.y - filterRadius), 0)),
165 max(std::min((
int) std::floor(pos.x + filterRadius), size.x - 1),
166 std::min((
int) std::floor(pos.y + filterRadius), size.y - 1));
169 for (
int x=min.x, idx = 0; x<=max.x; ++x)
170 m_weightsX[idx++] = m_filter->evalDiscretized(x-pos.x);
171 for (
int y=min.y, idx = 0; y<=max.y; ++y)
172 m_weightsY[idx++] = m_filter->evalDiscretized(y-pos.y);
175 for (
int y=min.y, yr=0; y<=max.y; ++y, ++yr) {
176 const Float weightY = m_weightsY[yr];
177 Float *dest = m_bitmap->getFloatData()
178 + (y * (size_t) size.x + min.x) * channels;
180 for (
int x=min.x, xr=0; x<=max.x; ++x, ++xr) {
181 const Float weight = m_weightsX[xr] * weightY;
183 for (
int k=0; k<channels; ++k)
184 *dest++ += weight * value[k];
193 std::ostringstream oss;
194 oss <<
"Invalid sample value : [";
195 for (
int i=0; i<channels; ++i) {
201 Log(
EWarn,
"%s", oss.str().c_str());
209 m_bitmap->getSize() -
Vector2i(2*m_borderSize, 2*m_borderSize), m_filter, m_bitmap->getChannelCount());
TVector2< int > Vector2i
Definition: fwd.h:108
const Bitmap * getBitmap() const
Return a pointer to the underlying bitmap representation (const version)
Definition: imageblock.h:97
General-purpose bitmap class with read and write support for several common file formats.
Definition: bitmap.h:50
virtual void save(Stream *stream) const =0
Serialize a work result to a binary data stream.
bool getWarn() const
Warn when writing bad sample values?
Definition: imageblock.h:79
void setWarn(bool warn)
Warn when writing bad sample values?
Definition: imageblock.h:82
int getChannelCount() const
Return the number of channels stored by the image block.
Definition: imageblock.h:88
EPixelFormat
Definition: bitmap.h:61
void clear()
Clear everything to zero.
Definition: imageblock.h:100
Generic interface to separable image reconstruction filters.
Definition: rfilter.h:44
FINLINE bool put(const Point2 &_pos, const Float *value)
Store a single sample inside the block.
Definition: imageblock.h:144
Vector2i m_size
Definition: imageblock.h:240
void put(const ImageBlock *block)
Accumulate another image block into this one.
Definition: imageblock.h:103
Bitmap::EPixelFormat getPixelFormat() const
Return the underlying pixel format.
Definition: imageblock.h:91
Abstract work result – represents the result of a processed WorkUnit instance.
Definition: sched.h:80
void setOffset(const Point2i &offset)
Set the current block offset.
Definition: imageblock.h:61
const Point2i & getOffset() const
Return the current block offset.
Definition: imageblock.h:64
#define Log(level, fmt,...)
Write a Log message to the console (to be used within subclasses of Object)
Definition: logger.h:35
Bitmap * getBitmap()
Return a pointer to the underlying bitmap representation.
Definition: imageblock.h:94
Abstract seekable stream class.
Definition: stream.h:58
#define MTS_DECLARE_CLASS()
This macro must be used in the initial definition in classes that derive from Object.
Definition: class.h:158
Reference counting helper.
Definition: ref.h:40
Warning message.
Definition: formatter.h:32
const Vector2i & getSize() const
Return the current block size.
Definition: imageblock.h:70
void copyTo(ImageBlock *copy) const
Copy the contents of this image block to another one with the same configuration. ...
Definition: imageblock.h:215
int getWidth() const
Return the bitmap's width in pixels.
Definition: imageblock.h:73
Point2i m_offset
Definition: imageblock.h:239
uint8_t * getUInt8Data()
Access the underlying raster (for uint8 bitmaps)
Definition: bitmap.h:1192
virtual void load(Stream *stream)=0
Fill the work result with content acquired from a binary data stream.
int getBorderSize() const
Return the border region used by the reconstruction filter.
Definition: imageblock.h:85
Storage for an image sub-block (a.k.a render bucket)
Definition: imageblock.h:40
FINLINE bool put(const Point2 &pos, const Spectrum &spec, Float alpha)
Store a single sample inside the image block.
Definition: imageblock.h:124
bool m_warn
Definition: imageblock.h:244
virtual std::string toString() const =0
Return a string representation.
TPoint2< int > Point2i
Definition: fwd.h:131
Discrete spectral power distribution based on a number of wavelength bins over the 360-830 nm range...
Definition: spectrum.h:663
void setSize(const Vector2i &size)
Set the current block size.
Definition: imageblock.h:67
ref< ImageBlock > clone() const
Create a clone of the entire image block.
Definition: imageblock.h:207
int getHeight() const
Return the bitmap's height in pixels.
Definition: imageblock.h:76