Commit ceb6d9b2 authored by Kenneth Moreland's avatar Kenneth Moreland
Browse files

Correct background in icetSingleImageCollect.

This also enables background correction in the sequential and reduce
strategies.
parent 19caca87
......@@ -107,9 +107,10 @@ documentation.)
icetSendRecvLargeMessages takes const array for messageDestinations.
ICET_CORRECT_COLORED_BACKGROUND is now the responsibility of the strategy,
not done automatically.
not done automatically. icetSingleImageCollect does it for you, though.
Added internal state variables ICET_NEED_BACKGROUND_CORRECTION,
ICET_TRUE_BACKGROUND_COLOR, and ICET_TRUE_BACKGROUND_COLOR_WORD.
icetImageCorrectBackground function.
icetImageCorrectBackground, icetDecompressImageCorrectBackground, and
icetDecompressSubImageCorrectBackground functions.
......@@ -34,6 +34,9 @@
* values.
* BLEND_RGBA_FLOAT(src, dest) - same as above except src and dest
* are IceTFloat arrays.
* CORRECT_BACKGROUND - if defined, the output color will be blended
* with the true background color. This should only be set
* if ICET_NEED_BACKGROUND_CORRECTION is true.
* OFFSET - If defined to a number (or variable holding a number), skips
* that many pixels at the beginning of the image.
* PIXEL_COUNT - If defined to a number (or a variable holding a number),
......@@ -247,11 +250,21 @@
#ifdef OFFSET
_color += OFFSET;
#endif
#ifdef CORRECT_BACKGROUND
icetGetIntegerv(ICET_TRUE_BACKGROUND_COLOR_WORD,
(IceTInt *)&_background_color);
#else
icetGetIntegerv(ICET_BACKGROUND_COLOR_WORD,
(IceTInt *)&_background_color);
#endif
#ifdef COMPOSITE
#define COPY_PIXEL(c_src, c_dest) \
BLEND_RGBA_UBYTE(((IceTUByte*)c_src), ((IceTUByte*)c_dest))
#elif defined(CORRECT_BACKGROUND)
#define COPY_PIXEL(c_src, c_dest) \
ICET_BLEND_UBYTE(((IceTUByte*)c_src), \
((IceTUByte*)&_background_color), \
((IceTUByte*)c_dest))
#else
#define COPY_PIXEL(c_src, c_dest) \
c_dest[0] = c_src[0];
......@@ -282,9 +295,16 @@
#ifdef OFFSET
_color += 4*(OFFSET);
#endif
#ifdef CORRECT_BACKGROUND
icetGetFloatv(ICET_TRUE_BACKGROUND_COLOR, _background_color);
#else
icetGetFloatv(ICET_BACKGROUND_COLOR, _background_color);
#endif
#ifdef COMPOSITE
#define COPY_PIXEL(c_src, c_dest) BLEND_RGBA_FLOAT(c_src, c_dest);
#elif defined(CORRECT_BACKGROUND)
#define COPY_PIXEL(c_src, c_dest) \
ICET_BLEND_FLOAT(c_src, _background_color, c_dest);
#else
#define COPY_PIXEL(c_src, c_dest) \
c_dest[0] = c_src[0]; \
......
......@@ -2002,6 +2002,47 @@ void icetDecompressSubImage(const IceTSparseImage compressed_image,
#include "decompress_func_body.h"
}
void icetDecompressImageCorrectBackground(const IceTSparseImage compressed_image,
IceTImage image)
{
icetImageSetDimensions(image,
icetSparseImageGetWidth(compressed_image),
icetSparseImageGetHeight(compressed_image));
icetDecompressSubImageCorrectBackground(compressed_image, 0, image);
}
void icetDecompressSubImageCorrectBackground(
const IceTSparseImage compressed_image,
IceTSizeType offset,
IceTImage image)
{
IceTBoolean need_correction;
const IceTFloat *background_color;
const IceTUByte *background_color_word;
icetGetBooleanv(ICET_NEED_BACKGROUND_CORRECTION, &need_correction);
if (!need_correction) {
/* Do a normal decompress. */
icetDecompressSubImage(compressed_image, offset, image);
}
ICET_TEST_IMAGE_HEADER(image);
ICET_TEST_SPARSE_IMAGE_HEADER(compressed_image);
background_color = icetUnsafeStateGetFloat(ICET_TRUE_BACKGROUND_COLOR);
background_color_word =
(IceTUByte*)icetUnsafeStateGetInteger(ICET_TRUE_BACKGROUND_COLOR_WORD);
#define INPUT_SPARSE_IMAGE compressed_image
#define OUTPUT_IMAGE image
#define TIME_DECOMPRESSION
#define OFFSET offset
#define PIXEL_COUNT icetSparseImageGetNumPixels(compressed_image)
#define CORRECT_BACKGROUND
#include "decompress_func_body.h"
}
void icetComposite(IceTImage destBuffer, const IceTImage srcBuffer,
int srcOnTop)
......
......@@ -153,6 +153,15 @@ ICET_EXPORT void icetDecompressSubImage(const IceTSparseImage compressed_image,
IceTSizeType offset,
IceTImage image);
ICET_EXPORT void icetDecompressImageCorrectBackground(
const IceTSparseImage compressed_image,
IceTImage image);
ICET_EXPORT void icetDecompressSubImageCorrectBackground(
const IceTSparseImage compressed_image,
IceTSizeType offset,
IceTImage image);
ICET_EXPORT void icetComposite(IceTImage destBuffer,
const IceTImage srcBuffer,
int srcOnTop);
......
......@@ -672,7 +672,9 @@ void icetSingleImageCollect(const IceTSparseImage input_image,
if (piece_size > 0) {
/* Decompress data into appropriate offset of result image. */
icetDecompressSubImage(input_image, piece_offset, result_image);
icetDecompressSubImageCorrectBackground(input_image,
piece_offset,
result_image);
} else if (rank != dest) {
/* If this function is called for multiple collections, it is likely
that the local process will not have data for all collections. To
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment