32 #ifndef OPENIMAGEIO_IMAGEBUFALGO_H
33 #define OPENIMAGEIO_IMAGEBUFALGO_H
38 # pragma warning (disable : 4251)
49 #ifndef __OPENCV_CORE_TYPES_H__
91 namespace ImageBufAlgo {
111 bool OIIO_API zero (ImageBuf &dst, ROI roi=ROI::All(),
int nthreads=0);
134 bool OIIO_API fill (ImageBuf &dst,
const float *values,
135 ROI roi=ROI::All(),
int nthreads=0);
138 inline bool OIIO_API fill (ImageBuf &dst,
const float *pixel,
139 int xbegin,
int xend,
int ybegin,
int yend,
140 int zbegin=0,
int zend=1) {
141 return fill (dst, pixel, ROI(xbegin,xend,ybegin,yend,zbegin,zend));
168 bool OIIO_API checker (ImageBuf &dst,
int width,
int height,
int depth,
169 const float *color1,
const float *color2,
170 int xoffset,
int yoffset,
int zoffset,
171 ROI roi=ROI::All(),
int nthreads=0);
174 bool OIIO_API checker (ImageBuf &dst,
int width,
175 const float *color1,
const float *color2,
176 int xbegin,
int xend,
int ybegin,
int yend,
177 int zbegin=0,
int zend=1);
205 bool OIIO_API channels (ImageBuf &dst,
const ImageBuf &src,
206 int nchannels,
const int *channelorder,
207 const float *channelvalues=NULL,
208 const std::string *newchannelnames=NULL,
209 bool shuffle_channel_names=
false);
213 bool OIIO_API channels (ImageBuf &dst,
const ImageBuf &src,
214 int nchannels,
const int *channelorder,
215 bool shuffle_channel_names);
219 bool OIIO_API setNumChannels(ImageBuf &dst,
const ImageBuf &src,
int numChannels);
227 bool OIIO_API channel_append (ImageBuf &dst,
const ImageBuf &A,
228 const ImageBuf &B, ROI roi=ROI::All(),
243 bool OIIO_API crop (ImageBuf &dst,
const ImageBuf &src,
244 ROI roi = ROI::All(),
int nthreads = 0);
261 bool OIIO_API paste (ImageBuf &dst,
int xbegin,
int ybegin,
262 int zbegin,
int chbegin,
263 const ImageBuf &src, ROI srcroi=ROI::All(),
285 bool OIIO_API flip (ImageBuf &dst,
const ImageBuf &src,
286 ROI roi=ROI::All(),
int nthreads=0);
306 bool OIIO_API flop (ImageBuf &dst,
const ImageBuf &src,
307 ROI roi=ROI::All(),
int nthreads=0);
328 bool OIIO_API flipflop (ImageBuf &dst,
const ImageBuf &src,
329 ROI roi=ROI::All(),
int nthreads=0);
350 bool OIIO_API transpose (ImageBuf &dst,
const ImageBuf &src,
351 ROI roi=ROI::All(),
int nthreads=0);
373 bool OIIO_API circular_shift (ImageBuf &dst,
const ImageBuf &src,
374 int xshift,
int yshift,
int zshift=0,
375 ROI roi=ROI::All(),
int nthreads=0);
396 bool OIIO_API clamp (ImageBuf &dst,
397 const float *min=NULL,
const float *max=NULL,
398 bool clampalpha01 =
false,
399 ROI roi = ROI::All(),
int nthreads = 0);
416 bool OIIO_API clamp (ImageBuf &dst,
417 float min=-std::numeric_limits<float>::max(),
418 float max=std::numeric_limits<float>::max(),
419 bool clampalpha01 =
false,
420 ROI roi = ROI::All(),
int nthreads = 0);
439 bool OIIO_API add (ImageBuf &dst,
const ImageBuf &A,
const ImageBuf &B,
440 ROI roi=ROI::All(),
int nthreads=0);
454 bool OIIO_API add (ImageBuf &dst,
float val,
455 ROI roi=ROI::All(),
int nthreads=0);
470 bool OIIO_API add (ImageBuf &dst,
const float *val,
471 ROI roi=ROI::All(),
int nthreads=0);
475 bool OIIO_API add (ImageBuf &dst,
const ImageBuf &A,
const ImageBuf &B,
int options);
479 enum OIIO_API AddOptions
484 ADD_RETAIN_WINDOWS = 2,
485 ADD_ALIGN_WINDOWS = 0,
505 bool OIIO_API sub (ImageBuf &dst,
const ImageBuf &A,
const ImageBuf &B,
506 ROI roi=ROI::All(),
int nthreads=0);
524 bool OIIO_API mul (ImageBuf &dst,
const ImageBuf &A,
const ImageBuf &B,
525 ROI roi=ROI::All(),
int nthreads=0);
540 bool OIIO_API mul (ImageBuf &dst,
float val,
541 ROI roi=ROI::All(),
int nthreads=0);
556 bool OIIO_API mul (ImageBuf &dst,
const float *val,
557 ROI roi=ROI::All(),
int nthreads=0);
575 bool OIIO_API channel_sum (ImageBuf &dst,
const ImageBuf &src,
576 const float *weights=NULL, ROI roi=ROI::All(),
608 bool OIIO_API rangecompress (ImageBuf &dst,
bool useluma =
true,
609 ROI roi = ROI::All(),
int nthreads=0);
614 bool OIIO_API rangeexpand (ImageBuf &dst,
bool useluma =
true,
615 ROI roi = ROI::All(),
int nthreads=0);
634 bool OIIO_API colorconvert (ImageBuf &dst,
const ImageBuf &src,
635 const ColorProcessor *processor,
637 ROI roi=ROI::All(),
int nthreads=0);
646 bool OIIO_API colorconvert (
float *color,
int nchannels,
647 const ColorProcessor *processor,
bool unpremult);
663 bool OIIO_API unpremult (ImageBuf &dst, ROI roi = ROI::All(),
int nthreads = 0);
680 bool OIIO_API premult (ImageBuf &dst, ROI roi = ROI::All(),
int nthreads = 0);
684 struct OIIO_API PixelStats {
685 std::vector<float> min;
686 std::vector<float> max;
687 std::vector<float> avg;
688 std::vector<float> stddev;
689 std::vector<imagesize_t> nancount;
690 std::vector<imagesize_t> infcount;
691 std::vector<imagesize_t> finitecount;
692 std::vector<double> sum, sum2;
708 bool OIIO_API computePixelStats (PixelStats &stats,
const ImageBuf &src,
709 ROI roi=ROI::All(),
int nthreads=0);
717 struct CompareResults {
718 double meanerror, rms_error, PSNR, maxerror;
719 int maxx, maxy, maxz, maxc;
720 imagesize_t nwarn, nfail;
740 bool OIIO_API compare (
const ImageBuf &A,
const ImageBuf &B,
741 float failthresh,
float warnthresh,
742 CompareResults &result,
743 ROI roi = ROI::All(),
int nthreads=0);
765 int OIIO_API compare_Yee (
const ImageBuf &A,
const ImageBuf &B,
766 CompareResults &result,
767 float luminance = 100,
float fov = 45,
768 ROI roi = ROI::All(),
int nthreads = 0);
771 int OIIO_API compare_Yee (
const ImageBuf &A,
const ImageBuf &B,
772 float luminance = 100,
float fov = 45);
787 bool OIIO_API isConstantColor (
const ImageBuf &src,
float *color = NULL,
788 ROI roi = ROI::All(),
int nthreads=0);
802 bool OIIO_API isConstantChannel (
const ImageBuf &src,
int channel,
float val,
803 ROI roi = ROI::All(),
int nthreads = 0);
816 bool OIIO_API isMonochrome (
const ImageBuf &src,
817 ROI roi = ROI::All(),
int nthreads = 0);
842 bool OIIO_API color_count (
const ImageBuf &src,
844 int ncolors,
const float *color,
845 const float *eps=NULL,
846 ROI roi=ROI::All(),
int nthreads=0);
868 bool OIIO_API color_range_check (
const ImageBuf &src,
869 imagesize_t *lowcount,
870 imagesize_t *highcount,
871 imagesize_t *inrangecount,
872 const float *low,
const float *high,
873 ROI roi=ROI::All(),
int nthreads=0);
887 OIIO_API ROI nonzero_region (
const ImageBuf &src,
888 ROI roi=ROI::All(),
int nthreads=0);
900 std::string OIIO_API computePixelHashSHA1 (
const ImageBuf &src,
901 const std::string &extrainfo =
"",
902 ROI roi = ROI::All(),
903 int blocksize = 0,
int nthreads=0);
927 bool OIIO_API resize (ImageBuf &dst,
const ImageBuf &src,
928 Filter2D *filter=NULL,
929 ROI roi = ROI::All(),
int nthreads = 0);
932 bool OIIO_API resize (ImageBuf &dst,
const ImageBuf &src,
933 int xbegin,
int xend,
int ybegin,
int yend,
934 Filter2D *filter=NULL);
957 bool OIIO_API resample (ImageBuf &dst,
const ImageBuf &src,
958 bool interpolate =
true,
959 ROI roi = ROI::All(),
int nthreads = 0);
978 bool OIIO_API convolve (ImageBuf &dst,
const ImageBuf &src,
979 const ImageBuf &kernel,
bool normalize =
true,
980 ROI roi = ROI::All(),
int nthreads = 0);
1000 bool OIIO_API make_kernel (ImageBuf &dst,
const char *name,
1001 float width,
float height,
float depth = 1.0f,
1002 bool normalize =
true);
1032 bool OIIO_API unsharp_mask (ImageBuf &dst,
const ImageBuf &src,
1033 const char *kernel=
"gaussian",
float width = 3.0f,
1034 float contrast = 1.0f,
float threshold = 0.0f,
1035 ROI roi = ROI::All(),
int nthreads = 0);
1058 bool OIIO_API fft (ImageBuf &dst,
const ImageBuf &src,
1059 ROI roi = ROI::All(),
int nthreads = 0);
1080 bool OIIO_API ifft (ImageBuf &dst,
const ImageBuf &src,
1081 ROI roi = ROI::All(),
int nthreads = 0);
1084 enum OIIO_API NonFiniteFixMode
1087 NONFINITE_BLACK = 1,
1114 bool OIIO_API fixNonFinite (ImageBuf &dst, NonFiniteFixMode mode=NONFINITE_BOX3,
1115 int *pixelsFixed = NULL,
1116 ROI roi = ROI::All(),
int nthreads = 0);
1121 bool OIIO_API fixNonFinite (ImageBuf &dst,
const ImageBuf &src,
1122 NonFiniteFixMode mode = NONFINITE_BOX3,
1123 int *pixelsFixed = NULL);
1141 bool OIIO_API fillholes_pushpull (ImageBuf &dst,
const ImageBuf &src,
1142 ROI roi = ROI::All(),
int nthreads = 0);
1152 bool OIIO_API from_IplImage (ImageBuf &dst,
const IplImage *ipl,
1153 TypeDesc convert=TypeDesc::UNKNOWN);
1160 OIIO_API IplImage* to_IplImage (
const ImageBuf &src);
1167 bool OIIO_API capture_image (ImageBuf &dst,
int cameranum = 0,
1168 TypeDesc convert=TypeDesc::UNKNOWN);
1207 bool OIIO_API over (ImageBuf &dst,
const ImageBuf &A,
const ImageBuf &B,
1208 ROI roi = ROI::All(),
int threads = 0);
1216 bool OIIO_API zover (ImageBuf &dst,
const ImageBuf &A,
const ImageBuf &B,
1217 bool z_zeroisinf =
false,
1218 ROI roi = ROI::All(),
int threads = 0);
1221 bool OIIO_API zover (ImageBuf &R,
const ImageBuf &A,
const ImageBuf &B,
1222 ROI roi,
int threads = 0);
1234 bool OIIO_API render_text (ImageBuf &R,
int x,
int y,
1235 const std::string &text,
1236 int fontsize=16,
const std::string &fontname=
"",
1237 const float *textcolor = NULL);
1257 bool OIIO_API histogram (
const ImageBuf &A,
int channel,
1258 std::vector<imagesize_t> &histogram,
int bins=256,
1259 float min=0,
float max=1, imagesize_t *submin=NULL,
1260 imagesize_t *supermax=NULL, ROI roi=ROI::All());
1271 bool OIIO_API histogram_draw (ImageBuf &R,
1272 const std::vector<imagesize_t> &histogram);
1276 enum OIIO_API MakeTextureMode {
1277 MakeTxTexture, MakeTxShadow, MakeTxEnvLatl,
1278 MakeTxEnvLatlFromLightProbe,
1409 bool OIIO_API make_texture (MakeTextureMode mode,
1410 const ImageBuf &input,
1411 const std::string &outputfilename,
1412 const ImageSpec &config,
1413 std::ostream *outstream = NULL);
1417 bool OIIO_API make_texture (MakeTextureMode mode,
1418 const std::string &filename,
1419 const std::string &outputfilename,
1420 const ImageSpec &config,
1421 std::ostream *outstream = NULL);
1425 bool OIIO_API make_texture (MakeTextureMode mode,
1426 const std::vector<std::string> &filenames,
1427 const std::string &outputfilename,
1428 const ImageSpec &config,
1429 std::ostream *outstream = NULL);
1439 #endif // OPENIMAGEIO_IMAGEBUFALGO_H