70 vector<ossim_uint8 *>::iterator iter =
m_buffers.begin();
107 static const ossim_uint8 MASK_BITS_0[] = {0x7F, 0xBF, 0xDF, 0xEF, 0xF7, 0xFB, 0xFD, 0xFE};
108 static const ossim_uint8 MASK_BITS_1[] = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01};
131 ossim_uint32 size_of_maskbuf = num_mask_rows * num_mask_cols;
133 memset(maskbuf, 0, size_of_maskbuf);
140 ossim_uint32 mask_index = 0, tile_index = 0, start_bit = 0;
146 for (
int y = ul.y; (
y <= lr.y) && (
y < image_size.
y);
y++)
148 mask_index =
y * num_mask_cols + ul.x / 8;
149 start_bit = ul.x % 8;
151 for (
int x = ul.x; (
x <= lr.x); )
153 if (
x < image_size.
x)
156 maskbuf[mask_index] = 0;
157 for (
ossim_uint32 mask_bit = start_bit; mask_bit < 8; ++mask_bit)
160 if (flipTile->
isNull(tile_index++))
161 maskbuf[mask_index] &= MASK_BITS_0[mask_bit];
163 maskbuf[mask_index] |= MASK_BITS_1[mask_bit];
167 if ((
x >= image_size.
x) || (
x > lr.x))
190 static const char *MODULE =
"ossimBitMaskWriter::writeMask()";
197 " for writing because output file name was never initialized.";
202 if (!maskFileStream.is_open())
215 maskFileStream << ends;
218 for (
ossim_uint32 rlevel = 0; rlevel < num_rlevels; ++rlevel)
221 maskFileStream.write((
char *)(
m_buffers[rlevel]), bufsize);
224 maskFileStream.close();
250 if (!kw_value.
empty())
289 return (ois != NULL);
296 bool makeOutputConnection,
297 bool createEventFlag)
300 if (input_source == NULL)
316 input_source->
accept(visitor);
369 isize.
x = (isize.
x + 1) / 2;
370 isize.
y = (isize.
y + 1) / 2;
375 isize.
x = ((int)(isize.
x + 7) / 8) * 8;
393 if (
m_buffers.size() == total_num_rlevels)
405 while (ovr_rlevel != total_num_rlevels)
408 ossimIpt ovr_size((ref_size.
x + 1) / 2, (ref_size.
y + 1) / 2);
410 if (size_of_ovrbuf == 0)
413 memset(ovr_buf, 0, size_of_ovrbuf);
419 for (
int y = 0;
y < ovr_size.
y;
y++)
421 ref_index = 2 *
y * ref_size.
x;
422 ovr_index =
y * ovr_size.
x;
424 for (
int x = 0;
x < ovr_size.
x;
x++)
428 if (ref_index < size_of_refbuf)
430 a = ref_buf[ref_index++];
431 if ((
x < (ovr_size.
x - 1)) || !(ref_size.
x & 1))
432 b = ref_buf[ref_index++];
434 ovr_buf[ovr_index++] = ((a & 0x80) |
448 size_of_refbuf = size_of_ovrbuf;
virtual ossim_uint32 getWidth() const
ossimFilename noExtension() const
ossimIpt m_imageSize
Size of full res source image.
void setBogusPixelRange(double min, double max)
Sets the range of pixels (inclusive) to be regarded as NULL pixels when computing mask...
static const char * OUTPUT_FILE_KW
static const char * BM_STARTING_RLEVEL_KW
bool buildOverviews(ossim_uint32 total_num_rlevels)
For imagery that already has overviews built, but with artifact edge pixels (such as JP2- compressed ...
Represents serializable keyword/value map.
vector< ossimIpt > m_bufferSizes
ossim_uint32 m_startingResLevel
const char * find(const char *key) const
static const char * MASK_FILE_MAGIC_NUMBER
bool contains(char aChar) const
ossimBitMaskWriter()
Default constructor typically used when reading a mask from disk.
void setImage(ossimRefPtr< ossimImageData > image)
virtual ossim_uint32 getHeight() const
ossim_uint32 toUInt32() const
vector< ossim_uint8 * > m_buffers
virtual bool loadState(const ossimKeywordlist &spec, const char *prefix=0)
Computes and writes the mask file according to the specification in the KWL.
virtual void initialize()
Initializes the state of the object from theInputConnection.
void setReplacementMode(ossimPixelFlipper::ReplacementMode mode)
ossimString theOutputName
void initializeFlipper()
Initializes the flipper (used for identifying pixels for masking) to default values.
bool isNull(ossim_uint32 offset) const
ossimRefPtr< ossimMemoryImageSource > m_memoryImage
virtual const ossimFilename & getFilename() const
Returns the filename.
unsigned int ossim_uint32
const char * chars() const
For backward compatibility.
virtual ossimIrect getImageRectangle() const
void setBogusPixel(double pixel_value)
Sets the NULL pixel value to consider when computing mask:
virtual ossim_int32 connectMyInputTo(ossimConnectableObject *inputObject, bool makeOutputConnection=true, bool createEventFlag=true)
Will try to connect this objects input to the passed in object.
virtual ossimRefPtr< ossimImageData > getTile(const ossimIrect &tile_rect, ossim_uint32 resLevel=0)
ossimObject * getObject(ossim_uint32 idx=0)
void generateMask(ossimRefPtr< ossimImageData > tile, ossim_uint32 rLevel)
Given a source's tile, derives the alpha mask and saves it in buffer for later writing to disk...
virtual bool isOpen() const
ossimRefPtr< ossimPixelFlipper > m_flipper
void setTargetRange(ossim_float64 target_min, ossim_float64 target_max)
Instead of a single value for a target, this method allows for specifying a range of values to flip t...
ConnectableObjectList theInputObjectList
Holds a list of input objects.
void setReplacementValue(ossim_float64 replacement_value)
This class defines an abstract Handler which all image handlers(loaders) should derive from...
void setTargetValue(ossim_float64 target_value)
virtual ossim_int32 connectMyInputTo(ossimConnectableObject *inputObject, bool makeOutputConnection=true, bool createEventFlag=true)
Will try to connect this objects input to the passed in object.
Class to scan pixels and flip target dn value to a replacement dn value.
virtual void close()
Writes the mask file to path specified. Returns TRUE if successful.
ossimIpt computeImageSize(ossim_uint32 rlevel, ossimImageData *tile) const
Since overviews may not yet exist when the mask is being written, we must compute the size of the sou...
virtual bool canConnectMyInputTo(ossim_int32 myInputIndex, const ossimConnectableObject *object) const
required to be overriden by derived classes
void reset()
Deletes allocated buffers and resets all values to defaults.
virtual void accept(ossimVisitor &visitor)
We will add a visitor interface for all connectable objects.
virtual ossimIrect getBoundingRect(ossim_uint32 resLevel=0) const
Returns zero-based bounding rectangle of the image.
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Method to the load (recreate) the state of an object from a keyword list.
std::basic_ofstream< char > ofstream
Class for char output file streams.
virtual void disconnectAllInputs()
Will disconnect all of the input objects.
ossimFilename & setExtension(const ossimString &e)
Sets the extension of a file name.
unsigned char ossim_uint8
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)