Commit d3b63a45 authored by Makayla Shepherd's avatar Makayla Shepherd
Browse files

Added UnsignedWord capabilities to ISIS. Fixes #3912.

git-svn-id: http://subversion.wr.usgs.gov/repos/prog/isis3/trunk@6814 41f8697f-d340-4b68-9986-7bafba869bb8
parent 1834c568
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -859,6 +859,12 @@ namespace Isis {
      m_multiplier = (max - min) / (x2 - x1);
      m_base = min - m_multiplier * x1;
    }
    else if (m_pixelType == UnsignedWord) {
      x1 = VALID_MINU2;
      x2 = VALID_MAXU2;
      m_multiplier = (max - min) / (x2 - x1);
      m_base = min - m_multiplier * x1;
    }
  }


+77 −0
Original line number Diff line number Diff line
@@ -1465,6 +1465,7 @@ namespace Isis {

              ((float *)buffersRawBuf)[bufferIndex] = raw;
            }
            
            else if(m_pixelType == SignedWord) {
              short raw = ((short *)chunkBuf)[chunkIndex];
              if(m_byteSwapper)
@@ -1490,6 +1491,38 @@ namespace Isis {

              ((short *)buffersRawBuf)[bufferIndex] = raw;
            }
            
            
            else if(m_pixelType == UnsignedWord) {
              unsigned short raw = ((unsigned short *)chunkBuf)[chunkIndex];
              if(m_byteSwapper)
                raw = m_byteSwapper->UnsignedShortInt(&raw);

              if(raw >= VALID_MINU2) {
                bufferVal = (double) raw * m_multiplier + m_base;
              }
              else if (raw > VALID_MAXU2) {
                if(raw == HIGH_INSTR_SATU2)
                  bufferVal = HIGH_INSTR_SAT8;
                else if(raw == HIGH_REPR_SATU2)
                  bufferVal = HIGH_REPR_SAT8;
                else
                  bufferVal = LOW_REPR_SAT8;
              }
              else {
                if(raw == NULLU2)
                  bufferVal = NULL8;
                else if(raw == LOW_INSTR_SATU2)
                  bufferVal = LOW_INSTR_SAT8;
                else if(raw == LOW_REPR_SATU2)
                  bufferVal = LOW_REPR_SAT8;
                else
                  bufferVal = LOW_REPR_SAT8;
              }

              ((unsigned short *)buffersRawBuf)[bufferIndex] = raw;
            }
            
            else if(m_pixelType == UnsignedByte) {
              unsigned char raw = ((unsigned char *)chunkBuf)[chunkIndex];

@@ -1651,6 +1684,50 @@ namespace Isis {
              ((short *)chunkBuf)[chunkIndex] =
                  m_byteSwapper ? m_byteSwapper->ShortInt(&raw) : raw;
            }
            else if(m_pixelType == UnsignedWord) {
              unsigned short raw;

              if(bufferVal >= VALID_MIN8) {
                double filePixelValueDbl = (bufferVal - m_base) /
                    m_multiplier;
                if(filePixelValueDbl < VALID_MINU2 - 0.5) {
                  raw = LOW_REPR_SATU2;
                }
                if(filePixelValueDbl > VALID_MAXU2 + 0.5) {
                  raw = HIGH_REPR_SATU2;
                }
                else {
                  int filePixelValue = (int)round(filePixelValueDbl);

                  if(filePixelValue < VALID_MINU2) {
                    raw = LOW_REPR_SATU2;
                  }
                  else if(filePixelValue > VALID_MAXU2) {
                    raw = HIGH_REPR_SATU2;
                  }
                  else {
                    raw = filePixelValue;
                  }
                }
              }
              else {
                if(bufferVal == NULL8)
                  raw = NULLU2;
                else if(bufferVal == LOW_INSTR_SAT8)
                  raw = LOW_INSTR_SATU2;
                else if(bufferVal == LOW_REPR_SAT8)
                  raw = LOW_REPR_SATU2;
                else if(bufferVal == HIGH_INSTR_SAT8)
                  raw = HIGH_INSTR_SATU2;
                else if(bufferVal == HIGH_REPR_SAT8)
                  raw = HIGH_REPR_SATU2;
                else
                  raw = LOW_REPR_SATU2;
              }

              ((unsigned short *)chunkBuf)[chunkIndex] =
                  m_byteSwapper ? m_byteSwapper->UnsignedShortInt(&raw) : raw;
            }
            else if(m_pixelType == UnsignedByte) {
              unsigned char raw;

+1 −0
Original line number Diff line number Diff line
@@ -110,6 +110,7 @@ namespace Isis {
   *                           when cube dimensions and buffer shape are same size. Fixes #1689.
   *   @history 2015-01-30 Ian Humphrey - Modified destructor to free m_writThreadMutex to 
   *                           prevent memory leaks upon destruction. Fixes #2082.
   *   @history 2016-04-21 Makayla Shepherd - Added UnsignedWord pixel type handling.
   *
   */
  class CubeIoHandler {
+4 −1
Original line number Diff line number Diff line
@@ -385,6 +385,9 @@ namespace Isis {
      else if(pixelTypeAtt == "16BIT" || pixelTypeAtt == "16-BIT" || pixelTypeAtt == "SIGNEDWORD") {
        result = SignedWord;
      }
      else if(pixelTypeAtt == "16UBIT" || pixelTypeAtt == "16-UBIT" || pixelTypeAtt == "UNSIGNEDWORD") {
        result = UnsignedWord;
      }
      else if(pixelTypeAtt == "32BIT" || pixelTypeAtt == "32-BIT" || pixelTypeAtt == "REAL") {
        result = Real;
      }
@@ -437,7 +440,7 @@ namespace Isis {


  bool CubeAttributeOutput::isPixelType(QString attribute) const {
    return QRegExp("(8-?BIT|16-?BIT|32-?BIT|UNSIGNEDBYTE|SIGNEDWORD|REAL)").exactMatch(attribute);
    return QRegExp("(8-?BIT|16-?BIT|32-?BIT|UNSIGNEDBYTE|SIGNEDWORD|UNSIGNEDWORD|REAL)").exactMatch(attribute);
  }


+1 −0
Original line number Diff line number Diff line
@@ -129,6 +129,7 @@ namespace Isis {
   *                           code duplication. Updated to match current coding standards.
   *                           Added safety check capabilities for unrecognized attributes.
   *                           References #961.
   *   @history 2016-04-21 Makayla Shepherd - Added cases for UnsignedWord pixel type
   */
  template<typename ChildClass> class CubeAttribute {
    public:
Loading