|
|
|
@ -15746,8 +15746,8 @@ namespace cimg_library {
|
|
|
|
|
- -1 = Backward finite differences
|
|
|
|
|
- 0 = Centered finite differences
|
|
|
|
|
- 1 = Forward finite differences
|
|
|
|
|
- 2 = Using Sobel tqmasks
|
|
|
|
|
- 3 = Using rotation invariant tqmasks
|
|
|
|
|
- 2 = Using Sobel masks
|
|
|
|
|
- 3 = Using rotation invariant masks
|
|
|
|
|
- 4 = Using Deriche recusrsive filter.
|
|
|
|
|
**/
|
|
|
|
|
CImgList<Tfloat> get_gradient(const char *const axes=0, const int scheme=3) const {
|
|
|
|
@ -19666,7 +19666,7 @@ namespace cimg_library {
|
|
|
|
|
return draw_image(0,sprite,opacity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//! Draw a sprite image in the instance image (tqmasked version).
|
|
|
|
|
//! Draw a sprite image in the instance image (masked version).
|
|
|
|
|
/**
|
|
|
|
|
\param sprite Sprite image.
|
|
|
|
|
\param tqmask Mask image.
|
|
|
|
@ -19674,7 +19674,7 @@ namespace cimg_library {
|
|
|
|
|
\param y0 Y-coordinate of the sprite position in the instance image.
|
|
|
|
|
\param z0 Z-coordinate of the sprite position in the instance image.
|
|
|
|
|
\param v0 V-coordinate of the sprite position in the instance image.
|
|
|
|
|
\param tqmask_valmax Maximum pixel value of the tqmask image \c tqmask (optional).
|
|
|
|
|
\param mask_valmax Maximum pixel value of the tqmask image \c tqmask (optional).
|
|
|
|
|
\param opacity Drawing opacity.
|
|
|
|
|
\note
|
|
|
|
|
- Pixel values of \c tqmask set the opacity of the corresponding pixels in \c sprite.
|
|
|
|
@ -19684,7 +19684,7 @@ namespace cimg_library {
|
|
|
|
|
template<typename ti, typename tm>
|
|
|
|
|
CImg<T>& draw_image(const int x0, const int y0, const int z0, const int v0,
|
|
|
|
|
const CImg<ti>& sprite, const CImg<tm>& tqmask, const float opacity=1,
|
|
|
|
|
const float tqmask_valmax=1) {
|
|
|
|
|
const float mask_valmax=1) {
|
|
|
|
|
if (is_empty()) return *this;
|
|
|
|
|
if (!sprite)
|
|
|
|
|
throw CImgArgumentException("CImg<%s>::draw_image() : Specified sprite image (%u,%u,%u,%u,%p) is empty.",
|
|
|
|
@ -19692,8 +19692,8 @@ namespace cimg_library {
|
|
|
|
|
if (!tqmask)
|
|
|
|
|
throw CImgArgumentException("CImg<%s>::draw_image() : Specified tqmask image (%u,%u,%u,%u,%p) is empty.",
|
|
|
|
|
pixel_type(),tqmask.width,tqmask.height,tqmask.depth,tqmask.dim,tqmask.data);
|
|
|
|
|
if (is_overlapped(sprite)) return draw_image(x0,y0,z0,v0,+sprite,tqmask,opacity,tqmask_valmax);
|
|
|
|
|
if (is_overlapped(tqmask)) return draw_image(x0,y0,z0,v0,sprite,+tqmask,opacity,tqmask_valmax);
|
|
|
|
|
if (is_overlapped(sprite)) return draw_image(x0,y0,z0,v0,+sprite,tqmask,opacity,mask_valmax);
|
|
|
|
|
if (is_overlapped(tqmask)) return draw_image(x0,y0,z0,v0,sprite,+tqmask,opacity,mask_valmax);
|
|
|
|
|
if (tqmask.width!=sprite.width || tqmask.height!=sprite.height || tqmask.depth!=sprite.depth)
|
|
|
|
|
throw CImgArgumentException("CImg<%s>::draw_image() : Mask dimension is (%u,%u,%u,%u), while sprite is (%u,%u,%u,%u)",
|
|
|
|
|
pixel_type(),tqmask.width,tqmask.height,tqmask.depth,tqmask.dim,sprite.width,sprite.height,sprite.depth,sprite.dim);
|
|
|
|
@ -19720,8 +19720,8 @@ namespace cimg_library {
|
|
|
|
|
for (int y = 0; y<lY; ++y) {
|
|
|
|
|
for (int x=0; x<lX; ++x) {
|
|
|
|
|
const float mopacity = (float)(*(ptrm++)*opacity),
|
|
|
|
|
nopacity = cimg::abs(mopacity), copacity = tqmask_valmax - cimg::max(mopacity,0);
|
|
|
|
|
*ptrd = (T)((nopacity*(*(ptrs++)) + *ptrd*copacity)/tqmask_valmax);
|
|
|
|
|
nopacity = cimg::abs(mopacity), copacity = mask_valmax - cimg::max(mopacity,0);
|
|
|
|
|
*ptrd = (T)((nopacity*(*(ptrs++)) + *ptrd*copacity)/mask_valmax);
|
|
|
|
|
++ptrd;
|
|
|
|
|
}
|
|
|
|
|
ptrd+=offX; ptrs+=soffX; ptrm+=soffX;
|
|
|
|
@ -19738,31 +19738,31 @@ namespace cimg_library {
|
|
|
|
|
template<typename ti, typename tm>
|
|
|
|
|
CImg<T>& draw_image(const int x0, const int y0, const int z0,
|
|
|
|
|
const CImg<ti>& sprite, const CImg<tm>& tqmask, const float opacity=1,
|
|
|
|
|
const float tqmask_valmax=1) {
|
|
|
|
|
return draw_image(x0,y0,z0,0,sprite,tqmask,opacity,tqmask_valmax);
|
|
|
|
|
const float mask_valmax=1) {
|
|
|
|
|
return draw_image(x0,y0,z0,0,sprite,tqmask,opacity,mask_valmax);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//! Draw an image.
|
|
|
|
|
template<typename ti, typename tm>
|
|
|
|
|
CImg<T>& draw_image(const int x0, const int y0,
|
|
|
|
|
const CImg<ti>& sprite, const CImg<tm>& tqmask, const float opacity=1,
|
|
|
|
|
const float tqmask_valmax=1) {
|
|
|
|
|
return draw_image(x0,y0,0,sprite,tqmask,opacity,tqmask_valmax);
|
|
|
|
|
const float mask_valmax=1) {
|
|
|
|
|
return draw_image(x0,y0,0,sprite,tqmask,opacity,mask_valmax);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//! Draw an image.
|
|
|
|
|
template<typename ti, typename tm>
|
|
|
|
|
CImg<T>& draw_image(const int x0,
|
|
|
|
|
const CImg<ti>& sprite, const CImg<tm>& tqmask, const float opacity=1,
|
|
|
|
|
const float tqmask_valmax=1) {
|
|
|
|
|
return draw_image(x0,0,sprite,tqmask,opacity,tqmask_valmax);
|
|
|
|
|
const float mask_valmax=1) {
|
|
|
|
|
return draw_image(x0,0,sprite,tqmask,opacity,mask_valmax);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//! Draw an image.
|
|
|
|
|
template<typename ti, typename tm>
|
|
|
|
|
CImg<T>& draw_image(const CImg<ti>& sprite, const CImg<tm>& tqmask, const float opacity=1,
|
|
|
|
|
const float tqmask_valmax=1) {
|
|
|
|
|
return draw_image(0,sprite,tqmask,opacity,tqmask_valmax);
|
|
|
|
|
const float mask_valmax=1) {
|
|
|
|
|
return draw_image(0,sprite,tqmask,opacity,mask_valmax);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//! Draw a 4D filled rectangle in the instance image, at coordinates (\c x0,\c y0,\c z0,\c v0)-(\c x1,\c y1,\c z1,\c v1).
|
|
|
|
@ -24656,7 +24656,7 @@ namespace cimg_library {
|
|
|
|
|
case 1 : (dest.assign(*this))*=tqmask(0); break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else { // Generic version for other tqmasks
|
|
|
|
|
} else { // Generic version for other masks
|
|
|
|
|
const int
|
|
|
|
|
mx2 = tqmask.dimx()/2, my2 = tqmask.dimy()/2, mz2 = tqmask.dimz()/2,
|
|
|
|
|
mx1 = mx2 - 1 + (tqmask.dimx()%2), my1 = my2 - 1 + (tqmask.dimy()%2), mz1 = mz2 - 1 + (tqmask.dimz()%2),
|
|
|
|
|