Esempio n. 1
0
void NITFWriteControl::setImageSecurity(const six::Classification& c,
        nitf::ImageSubheader& subheader)
{
    //This requires a normalized name to get set correctly
    subheader.getImageSecurityClass().set(
        getNITFClassification(c.getLevel()));
    setSecurity(c, subheader.getSecurityGroup(), "IS");
}
void NITFReadControl::addImageClassOptions(nitf::ImageSubheader& subheader,
        six::Classification& c) const
{

    Parameter p;
    p = subheader.getImageSecurityClass().toString();
    c.fileOptions.setParameter("ISCLAS", p);
    addSecurityOptions(subheader.getSecurityGroup(), "IS", c.fileOptions);
}
Esempio n. 3
0
void ImageSegment::setSubheader(nitf::ImageSubheader & value)
{
    //release the one currently "owned"
    nitf::ImageSubheader sub = nitf::ImageSubheader(getNativeOrThrow()->subheader);
    sub.setManaged(false);

    //have the library manage the "new" one
    getNativeOrThrow()->subheader = value.getNative();
    value.setManaged(true);
}
Esempio n. 4
0
void MetadataReader::doBands(const std::string& key,
                             ::nitf::ImageSubheader& header)
{
    const int nbands = (int)header.getNumImageBands();
    for (int i=0; i<nbands; i++)
    {
        ::nitf::BandInfo bandinfo = header.getBandInfo(i);
        std::string subkey = key + ".BAND:" + std::to_string(i);
        doBand(subkey, bandinfo);
    }
}
void NITFReadControl::validateSegment(nitf::ImageSubheader subheader,
                                      const NITFImageInfo* info)
{
    const size_t numBandsSeg =
            static_cast<nitf::Uint32>(subheader.getNumImageBands());

    const std::string pjust = subheader.getPixelJustification().toString();
    // TODO: More validation in here!
    if (pjust != "R")
    {
        throw except::Exception(Ctxt("Expected right pixel justification"));
    }

    // The number of bytes per pixel, which we count to be 3 in the
    // case of 24-bit true color and 8 in the case of complex float
    // and 1 in the case of most SIDD data
    const size_t numBitsPerPixel =
            static_cast<nitf::Uint32>(subheader.getNumBitsPerPixel());
    const size_t numBytesPerPixel = (numBitsPerPixel + 7) / 8;
    const size_t numBytesSeg = numBytesPerPixel * numBandsSeg;

    const size_t nbpp = info->getData()->getNumBytesPerPixel();
    if (numBytesSeg != nbpp)
    {
        std::ostringstream ostr;
        ostr << "Expected [" << nbpp << "] bytes per pixel, found ["
             << numBytesSeg << "]";
        throw except::Exception(Ctxt(ostr.str()));
    }

    const size_t numCols = info->getData()->getNumCols();
    const size_t numColsSubheader =
            static_cast<nitf::Uint32>(subheader.getNumCols());

    if (numColsSubheader != numCols)
    {
        std::ostringstream ostr;
        ostr << "Invalid column width: was expecting [" << numCols
             << "], got [" << numColsSubheader << "]";
        throw except::Exception(Ctxt(ostr.str()));
    }

}
Esempio n. 6
0
void Writer::writeImageSubheader(nitf::ImageSubheader subheader,
                                 nitf::Version version,
                                 nitf::Off& comratOff)
{
    if (!nitf_Writer_writeImageSubheader(getNativeOrThrow(),
                                         subheader.getNativeOrThrow(),
                                         version,
                                         &comratOff,
                                         &error))
    {
        throw nitf::NITFException(&error);
    }
}
Esempio n. 7
0
void NITFWriteControl::setBlocking(const std::string& imode,
                                   const types::RowCol<size_t>& segmentDims,
                                   nitf::ImageSubheader& subheader)
{
    const bool isSICD = (mContainer->getDataType() == DataType::COMPLEX);

    nitf::Uint32 numRowsPerBlock;
    if (mOptions.hasParameter(OPT_NUM_ROWS_PER_BLOCK))
    {
        if (isSICD)
        {
            throw except::Exception(Ctxt("SICDs do not support blocking"));
        }

        numRowsPerBlock = static_cast<sys::Uint32_T>(
                mOptions.getParameter(OPT_NUM_ROWS_PER_BLOCK));
    }
    else
    {
        // Unblocked (per 2500C, if > 8192, should be set to 0)
        numRowsPerBlock = (segmentDims.row > 8192) ?
                0 : segmentDims.row;
    }

    nitf::Uint32 numColsPerBlock;
    if (mOptions.hasParameter(OPT_NUM_COLS_PER_BLOCK))
    {
        if (isSICD)
        {
            throw except::Exception(Ctxt("SICDs do not support blocking"));
        }

        numColsPerBlock = static_cast<sys::Uint32_T>(
                mOptions.getParameter(OPT_NUM_COLS_PER_BLOCK));
    }
    else
    {
        // Unblocked (per 2500C, if > 8192, should be set to 0)
        numColsPerBlock = (segmentDims.col > 8192) ? 0 : segmentDims.col;
    }

    subheader.setBlocking(segmentDims.row,
                          segmentDims.col,
                          numRowsPerBlock,
                          numColsPerBlock,
                          imode);
}
std::pair<int, int> NITFReadControl::getIndices(nitf::ImageSubheader& subheader)
{

    std::string imageID = subheader.getImageId().toString();
    str::trim(imageID);
    // There is definitely something in here
    std::pair<int, int> imageAndSegment;
    imageAndSegment.first = 0;
    imageAndSegment.second = 0;

    int iid = str::toType<int>(imageID.substr(4, 3));

    /*
     *  Always first = 0, second = N - 1 (where N is numSegments)
     *
     */
    if (mContainer->getDataType() == DataType::COMPLEX)
    {
        // We need to find the SICD data here, and there is
        // only one
        if (iid != 0)
        {
            imageAndSegment.second = iid - 1;
        }
    }
    /*
     *  First is always iid - 1
     *  Second is always str::toType<int>(substr(7)) - 1
     */
    else
    {
        // If its SIDD, we need to check the first three
        // digits within the IID
        imageAndSegment.first = iid - 1;
        imageAndSegment.second = str::toType<int>(imageID.substr(7)) - 1;
    }
    return imageAndSegment;
}
Esempio n. 9
0
void MetadataReader::doImageSubheader(const std::string& key,
                                      ::nitf::ImageSubheader& subheader)
{
    writeField(key, "IID1", subheader.getImageId());
    writeField(key, "IDATIM", subheader.getImageDateAndTime());
    writeField(key, "TGTID", subheader.getTargetId());
    writeField(key, "IID2", subheader.getImageTitle());
    writeField(key, "ISCLAS", subheader.getImageSecurityClass());
    
    ::nitf::FileSecurity security = subheader.getSecurityGroup();
    doSecurity(key, "I", security);

    writeField(key, "ENCRYP", subheader.getEncrypted());
    writeField(key, "ISORCE", subheader.getImageSource());
    writeField(key, "NROWS", subheader.getNumRows());
    writeField(key, "NCOLS", subheader.getNumCols());
    writeField(key, "PVTYPE", subheader.getPixelValueType());
    writeField(key, "IREP", subheader.getImageRepresentation());
    writeField(key, "ICAT", subheader.getImageCategory());
    writeField(key, "ABPP", subheader.getActualBitsPerPixel());
    writeField(key, "PJUST", subheader.getPixelJustification());
    writeField(key, "ICORDS", subheader.getImageCoordinateSystem());
    writeField(key, "IGEOLO", subheader.getCornerCoordinates());
    writeField(key, "NICOM", subheader.getNumImageComments());

    ::nitf::List list = subheader.getImageComments();
    doComments(key, list);
    
    writeField(key, "IC", subheader.getImageCompression());
    writeField(key, "COMRAT", subheader.getCompressionRate());
    writeField(key, "NBANDS", subheader.getNumImageBands());
    writeField(key, "XBANDS", subheader.getNumMultispectralImageBands());

    doBands(key, subheader);

    writeField(key, "ISYNC", subheader.getImageSyncCode());
    writeField(key, "IMODE", subheader.getImageMode());
    writeField(key, "NBPR", subheader.getNumBlocksPerRow());
    writeField(key, "NBPC", subheader.getNumBlocksPerCol());
    writeField(key, "NPPBH", subheader.getNumPixelsPerHorizBlock());
    writeField(key, "NPPVB", subheader.getNumPixelsPerVertBlock());
    writeField(key, "NBPP", subheader.getNumBitsPerPixel());
    writeField(key, "IDLVL", subheader.getImageDisplayLevel());
    writeField(key, "IALVL", subheader.getImageAttachmentLevel());
    writeField(key, "ILOC", subheader.getImageLocation());
    writeField(key, "IMAG", subheader.getImageMagnification());
}