void rms_abs_errors( float& rms, float& abs, image_view_t<dvec4> a, image_view_t<vec3> b) { if (a.width != b.width || a.height != b.height) { throw std::invalid_argument("Image view dimensions must match."); } rms = 0; abs = 0; for (size_t y = 0; y < a.height; ++y) { for (size_t x = 0; x < a.width; ++x) { vec3 d = glm::abs(vec3(a.at(x, y).xyz() / a.at(x, y).w) - b.at(x, y)); abs += d.x + d.y + d.z; rms += glm::dot(d, d); } } float num = float(a.width * a.height * 3); rms = sqrt(rms / num); abs = abs / num; }
void rms_abs_errors_windowed( float& rms, float& abs, image_view_t<dvec4> a, image_view_t<vec3> b, const ivec2& center, int radius) { if (a.width != b.width || a.height != b.height) { throw std::invalid_argument("Image view dimensions must match."); } rms = 0; abs = 0; float num = 0.0f; for (int y = glm::max(0, center.y - radius + 1); y < glm::min(center.y + radius, int(a.height)); ++y) { for (int x = glm::max(0, center.x - radius + 1); x < glm::min(center.x + radius, int(a.width)); ++x) { vec3 d = glm::abs(vec3(a.at(x, y).xyz() / a.at(x, y).w) - b.at(x, y)); abs += d.x + d.y + d.z; rms += glm::dot(d, d); num += 1.0f; } } rms = sqrt(rms / num); abs = abs / num; }
void make_color_bars( const image_view_t& view) { typedef detail::color_bars_fn deref_t; typedef deref_t::point_t point_t; typedef boost::gil::virtual_2d_locator<deref_t,false> locator_t; typedef boost::gil::image_view<locator_t> my_virt_view_t; point_t dims( view.width(), view.height()); my_virt_view_t bars( dims, locator_t( point_t(0,0), point_t(1,1), deref_t( dims))); boost::gil::copy_pixels( bars, view); }
void box_blur_rgba( const const_image_view_t& src, const image_view_t& tmp, const image_view_t& dst, float hradius, float vradius, int iters) { RAMEN_ASSERT( src.width() == tmp.height()); RAMEN_ASSERT( src.height() == tmp.width()); if( hradius == 0 && vradius == 0) { boost::gil::copy_pixels( src, dst); return; } box_blur_rgba_( src, tmp, dst, hradius, vradius, iters); }
void ocio_transform( const image_view_t& img, OCIO::ConstProcessorRcPtr proc) { RAMEN_ASSERT( proc); if( !proc->isNoOp()) tbb::parallel_for( tbb::blocked_range<int>( 0, img.height()), detail::ocio_transform_fun( img, proc), tbb::auto_partitioner()); }
void smart_blur_rgba( const const_image_view_t& src, const image_view_t& tmp, const image_view_t& dst, float stddevx, float stddevy, float thereshold) { // create kernel here int sizex = (int)( stddevx * 6 + 1) | 1; if( sizex == 1) sizex = 3; int sizey = (int)( stddevy * 6 + 1) | 1; if( sizey == 1) sizey = 3; float *kernel = new float[ std::max( sizex, sizey)]; make_gauss_kernel( kernel, sizex, stddevx); tbb::parallel_for( tbb::blocked_range<std::size_t>( 0, src.height()), smart_blur_fn( src, tmp, thereshold, kernel, sizex), tbb::auto_partitioner()); make_gauss_kernel( kernel, sizey, stddevy); tbb::parallel_for( tbb::blocked_range<std::size_t>( 0, tmp.height()), smart_blur_fn( tmp, dst, thereshold, kernel, sizey), tbb::auto_partitioner()); delete[] kernel; }
void invert_alpha( const const_image_view_t& src, const image_view_t& dst) { RAMEN_ASSERT( src.width() == dst.width()); RAMEN_ASSERT( src.height() == dst.height()); boost::gil::tbb_transform_pixels( src, dst, detail::invert_alpha_fun()); }
void resize( const const_image_view_t& src, const image_view_t& dst) { tbb::parallel_for( tbb::blocked_range<int>( 0, dst.height() + 1), detail::resize_fn<Sampler>( src, dst), tbb::auto_partitioner()); }
void convolve33( const const_image_view_t& src, const image_view_t& dst, const Imath::M33f& k) { RAMEN_ASSERT( src.dimensions() == dst.dimensions() && "convolve33: src and dst views must have the same size"); tbb::parallel_for( tbb::blocked_range<int>( 0, dst.height()), detail::convolve33_fun( src, dst, k), tbb::auto_partitioner()); }