HiRISE
 Observation

Image_Line.hh
Go to the documentation of this file.
1 /* HiRISE Image Line
2 
3 PIRL CVS ID: Image_Line.hh,v 1.37 2020/02/14 01:17:18 schaller Exp
4 
5 Copyright (C) 2004-2020 Arizona Board of Regents on behalf of the Lunar and
6 Planetary Laboratory at the University of Arizona.
7 
8 Licensed under the Apache License, Version 2.0 (the "License"); you may not use
9 this file except in compliance with the License. You may obtain a copy of the
10 License at
11 
12  http://www.apache.org/licenses/LICENSE-2.0
13 
14 Unless required by applicable law or agreed to in writing, software distributed
15 under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
16 CONDITIONS OF ANY KIND, either express or implied. See the License for the
17 specific language governing permissions and limitations under the License.
18 */
19 #ifndef _HiRISE_Image_Line_
20 #define _HiRISE_Image_Line_
21 
22 // UA::HiRISE
23 #include "Data_Component.hh"
24 #include "LUT.hh"
25 
26 #if defined (INCLUDE_PVL)
27 // idaeim::PVL
28 #include "PVL.hh"
29 #endif
30 
31 #include <iostream>
32 #include <string>
33 
34 namespace UA
35 {
36 namespace HiRISE
37 {
38 // Forward references.
39 class Line_Cache;
40 
41 /*******************************************************************************
42  Image_Line
43 */
111 : public Data_Component
112 {
113 public:
114 /*==============================================================================
115  Constants:
116 */
118 static const char* const
119  ID;
120 
122 static const char* const
124 
136  {
137  // Line header Elements:
141 
142  // Pixel Elements:
147 
148  // The total number of Elements:
150  };
151 
153 static const char*
154  NAMES[];
155 
157 static const unsigned int
160 static const unsigned int
163 static const unsigned int
166 static const unsigned int
168 
175 static const unsigned int
177 
187 static const unsigned int
189 
191 static const Index
193 
200 static const Index
202 
224 static const Index
226 
235 static const u_int_32
237 
242 static const u_int_8
244 
249 static const u_int_8
251 
256 static const u_int_8
258 
261 static const u_int_8
263 
271 static const u_int_32
273 
282  {
286  };
287 
289 static const char*
291 
293 static const unsigned int
295 
296 /*==============================================================================
297  Class (static) data:
298 */
308 static unsigned int
310 
311 /*==============================================================================
312  Constructors
313 */
320 Image_Line ();
321 
345  (
346  unsigned int bytes_per_pixel,
347  unsigned int total_pixels,
348  unsigned int total_lines = 0,
349  unsigned int channel_number = CCD_UNKNOWN,
350  std::istream* stream = NULL
351  );
352 
363 Image_Line (const Image_Line& component, bool duplicate = true);
364 
374 Image_Line& operator= (const Image_Line& component);
375 
381 virtual ~Image_Line ();
382 
383 /*==============================================================================
384  Accessors
385 */
386 /* Identification:
387 */
394 std::string id () const;
395 
401 const char* name () const;
402 
403 /*------------------------------------------------------------------------------
404  Line header
405 */
415 u_int_32 sync () const;
416 
426 Image_Line& sync (u_int_32 value);
427 
435 u_int_32 channel () const;
436 
445 Image_Line& channel (u_int_32 channel_number);
446 
455  {return Channel_Number;}
456 
467  {Channel_Number = channel_number; return *this;}
468 
473 u_int_32 line_number () const;
474 
481 
486 bool bad_line () const;
487 
493 Image_Line& bad_line (bool state);
494 
503 std::string bad_line_description () const;
504 
505 /*------------------------------------------------------------------------------
506  Pixels
507 */
521 Pixel_type pixel (Index index) const;
522 
532 Pixel_type operator[] (Index index) const;
533 
547 void pixel (Index index, Pixel_type value);
548 
558 Pixel_type buffer_pixel (Index index) const;
559 
571 void buffer_pixel (Index index, Pixel_type value);
572 
582 Pixel_type image_pixel (Index index) const;
583 
595 void image_pixel (Index index, Pixel_type value);
596 
606 Pixel_type black_pixel (Index index) const;
607 
619 void black_pixel (Index index, Pixel_type value);
620 
630 Pixel_type virtual_pixel (Index index) const;
631 
643 void virtual_pixel (Index index, Pixel_type value);
644 
645 /*------------------------------------------------------------------------------
646  Structure
647 */
658 unsigned int pixel_count () const
659  {return Pixels_per_Line;}
660 
678 Image_Line& pixel_count (unsigned int total_pixels);
679 
684 unsigned int pixel_bytes () const;
685 
696 Image_Line& pixel_bytes (unsigned int bytes_per_pixel);
697 
704 unsigned int total_lines () const
705  {return Total_Lines;}
706 
721 Image_Line& total_lines (unsigned int lines);
722 
727 static unsigned int calibration_lines ()
728  {return Calibration_Lines;}
729 
747 static void calibration_lines (unsigned int lines);
748 
782 void mirror ();
783 
805 Image_Line& lookup (const LUT& lut);
806 
826 Image_Line& pukool (Pixel_type *table);
827 
828 /*==============================================================================
829  Cache
830 */
837 std::istream& source () const;
838 
848 Image_Line& source (std::istream& stream);
849 
874 bool next ();
875 
887 unsigned int count () const;
888 
904 unsigned long long bytes_read () const;
905 
917 unsigned long long source_bytes () const;
918 
924 bool compressed_data () const;
925 
933 unsigned long long compressed_bytes () const;
934 
942 unsigned long long decompressed_bytes () const;
943 
955  {return Data_Cache;}
956 
972 bool synchronization_lost ();
973 
974 /*==============================================================================
975  Printing
976 */
990 std::ostream& print
991  (std::ostream& stream = std::cout, bool verbose = false) const;
992 
998 unsigned int width () const
999  {return Width;}
1000 
1009 Image_Line& width (unsigned int groups)
1010  {Width = groups; return *this;}
1011 
1012 #if defined (INCLUDE_PVL)
1013 /*==============================================================================
1014  PVL
1015 */
1024 idaeim::PVL::Aggregate* PVL () const;
1025 
1049 
1050 #endif // defined (INCLUDE_PVL)
1051 
1052 /*==============================================================================
1053  Validation
1054 */
1062 bool is_valid () const;
1063 
1064 /*==============================================================================
1065  Functions
1066 */
1075 static bool is_sync (void* data_at);
1076 
1094 static Sync_Type next_sync (std::istream& stream);
1095 
1096 protected:
1097 /*==============================================================================
1098  Data
1099 */
1101 unsigned int
1103 
1105 unsigned int
1107 
1109 unsigned int
1111 
1113 unsigned int
1115 
1117 Line_Cache
1119 
1120 /*..............................................................................
1121  List formatting
1122 */
1124 unsigned int
1126 
1127 }; // class Image_Line
1128 
1129 } // namespace HiRISE
1130 } // namespace UA
1131 #endif
A Data_Component provides a common, virtual interface for all HiRISE Observation data blocks.
Definition: Data_Component.hh:124
An Image_Line contains a cache of observation channel image pixel data.
Definition: Image_Line.hh:112
static const Index MAX_COMPONENT_BYTES
Total maximum number of bytes in the Data_Block.
Definition: Image_Line.hh:192
std::ostream & print(std::ostream &stream=std::cout, bool verbose=false) const
Prints the component structure and contents.
Definition: Image_Line.cc:1385
unsigned int Total_Lines
Total number of lines expected.
Definition: Image_Line.hh:1110
Pixel_type buffer_pixel(Index index) const
Gets a Buffer_Pixels Element value.
Definition: Image_Line.cc:473
unsigned int pixel_bytes() const
Gets the number of bytes per pixel.
Definition: Image_Line.cc:836
std::istream & source() const
Gets the istream being used as the source of line data.
Definition: Image_Line.cc:906
static const unsigned int DEFAULT_CALIBRATION_LINES
The default number of calibration lines at the beginning of the observation channel data.
Definition: Image_Line.hh:188
static const u_int_8 SYNC_3
Expected Sync Element MSB (byte 3) value.
Definition: Image_Line.hh:243
u_int_32 expected_channel() const
Gets the expected channel number for the line header.
Definition: Image_Line.hh:454
Pixel_type black_pixel(Index index) const
Gets a Black_Pixels Element value.
Definition: Image_Line.cc:511
Line_Cache * cache()
Gets the line's data management cache object.
Definition: Image_Line.hh:954
static unsigned int calibration_lines()
Gets the number of image lines designated as calibration data.
Definition: Image_Line.hh:727
unsigned long long source_bytes() const
Gets the amount (bytes) of source data that has been used.
Definition: Image_Line.cc:985
static const char * NAMES[]
The name of each Element.
Definition: Image_Line.hh:154
Elements
An Element refers to a data containing constituent of a component.
Definition: Image_Line.hh:136
@ Black_Pixels
Definition: Image_Line.hh:145
@ Total_Elements
Definition: Image_Line.hh:149
@ Channel
Definition: Image_Line.hh:139
@ Virtual_Pixels
Definition: Image_Line.hh:146
@ Sync
Definition: Image_Line.hh:138
@ Buffer_Pixels
Definition: Image_Line.hh:143
@ Line_Number
Definition: Image_Line.hh:140
@ Image_Pixels
Definition: Image_Line.hh:144
u_int_32 line_number() const
Gets the Line_Number Element value.
Definition: Image_Line.cc:366
static const unsigned int LINE_HEADER_BYTES
The number of bytes in the line header section.
Definition: Image_Line.hh:158
std::string id() const
Provides the class ID on a line followed by the base Data_Component::id.
Definition: Image_Line.cc:311
Pixel_type image_pixel(Index index) const
Gets an Image_Pixels Element value.
Definition: Image_Line.cc:492
Image_Line()
Constructs a default Image_Line.
Definition: Image_Line.cc:220
static const unsigned int MAX_PIXELS_PER_LINE
The maximum number of pixels allowed.
Definition: Image_Line.hh:176
static const u_int_32 LINE_NUMBER_MASK
Bit mask for the line number field of the Line_Number Element.
Definition: Image_Line.hh:272
u_int_32 channel() const
Gets the Channel Element channel number.
Definition: Image_Line.cc:339
static const u_int_8 SYNC_2
Expected Sync Element MSB+1 (byte 2) value.
Definition: Image_Line.hh:250
void mirror()
Mirrors the order of all pixels.
Definition: Image_Line.cc:683
unsigned long long bytes_read() const
Gets the number of bytes read from the data source.
Definition: Image_Line.cc:976
unsigned long long compressed_bytes() const
Gets the amount (bytes) of compressed data that has been processed.
Definition: Image_Line.cc:1003
static const unsigned int MAX_VIRTUAL_PIXELS_COUNT
The maximum number of allowable virtual pixels.
Definition: Image_Line.hh:167
Image_Line & width(unsigned int groups)
Sets the print listing width.
Definition: Image_Line.hh:1009
unsigned int Channel_Number
Expected channel number.
Definition: Image_Line.hh:1114
Pixel_type virtual_pixel(Index index) const
Gets a Virtual_Pixels Element value.
Definition: Image_Line.cc:529
static unsigned int Calibration_Lines
Number of image lines at the beginning of the image data to be designated as calibration data.
Definition: Image_Line.hh:309
unsigned long long decompressed_bytes() const
Gets the amount (bytes) of decompressed data that has been generated.
Definition: Image_Line.cc:1012
Sync_Type
Possible types of sync patterns.
Definition: Image_Line.hh:282
@ No_Sync_Type
Definition: Image_Line.hh:283
@ Line_Header_Sync_Type
Definition: Image_Line.hh:284
@ FELICS_Sync_Type
Definition: Image_Line.hh:285
unsigned int width() const
Gets the print listing width.
Definition: Image_Line.hh:998
bool compressed_data() const
Indicates if the source line data was FELICS compressed.
Definition: Image_Line.cc:994
bool next()
Gets the next image line.
Definition: Image_Line.cc:958
static const unsigned int BLACK_PIXELS_COUNT
The number of black pixels.
Definition: Image_Line.hh:164
const char * name() const
Gets the NAME of this class.
Definition: Image_Line.cc:316
static const u_int_32 SYNC
Expected Sync Element value after extension.
Definition: Image_Line.hh:236
bool is_valid() const
Tests if the component data is valid.
Definition: Image_Line.cc:1471
std::string bad_line_description() const
Gets the description of the bad line cause.
Definition: Image_Line.cc:400
static Sync_Type next_sync(std::istream &stream)
Searches an istream for an image data synchronization pattern.
Definition: Image_Line.cc:1518
static const Index ARRAY_COUNTS_TEMPLATE[][2]
Data_Block array element value counts each keyed to an Element Index.
Definition: Image_Line.hh:225
static const unsigned int BUFFER_PIXELS_COUNT
The number of buffer pixels.
Definition: Image_Line.hh:161
unsigned int total_lines() const
Gets the total number of image lines in the channel data set.
Definition: Image_Line.hh:704
static bool is_sync(void *data_at)
Tests if some data contains a line header sync pattern.
Definition: Image_Line.cc:1500
Pixel_type operator[](Index index) const
Gets a pixel value.
Definition: Image_Line.cc:460
static const u_int_8 CHANNEL_BIT_MASK
Bit mask for channel number field of the Channel Element.
Definition: Image_Line.hh:262
virtual ~Image_Line()
Destructor.
Definition: Image_Line.cc:302
unsigned int Bytes_per_Pixel
Bytes per pixel.
Definition: Image_Line.hh:1106
Image_Line & expected_channel(u_int_32 channel_number)
Sets the expected channel number for the line header.
Definition: Image_Line.hh:466
unsigned int Width
Width of listing (pixel groups).
Definition: Image_Line.hh:1125
unsigned int count() const
Gets the current line count.
Definition: Image_Line.cc:967
Image_Line & operator=(const Image_Line &component)
Assigns another Image_Line to this one.
Definition: Image_Line.cc:286
Image_Line & lookup(const LUT &lut)
Applies a LUT mapping to all pixel values.
Definition: Image_Line.cc:697
unsigned int pixel_count() const
Gets the total number of pixels in the line.
Definition: Image_Line.hh:658
unsigned int Pixels_per_Line
Total pixels in a line.
Definition: Image_Line.hh:1102
Line_Cache * Data_Cache
Line data cache.
Definition: Image_Line.hh:1118
Image_Line & pukool(Pixel_type *table)
Applies a "reverse" table mapping to all pixel values.
Definition: Image_Line.cc:743
static const u_int_8 SYNC_1_BIT_MASK
Bit mask for the Sync Element extension field of the Channel Element.
Definition: Image_Line.hh:257
static const unsigned int DEFAULT_WIDTH
The default width, in pixel groups, of a print listing.
Definition: Image_Line.hh:294
static const char *const ID
Class identification name with source code version and date.
Definition: Image_Line.hh:119
static const char * Sync_Type_Names[]
Sync_Type names.
Definition: Image_Line.hh:290
static const Index OFFSETS_TEMPLATE[]
Data_Block data storage address offset template for each Element.
Definition: Image_Line.hh:201
static const char *const NAME
The component name.
Definition: Image_Line.hh:123
bool synchronization_lost()
Check for lost line synchronization.
Definition: Image_Line.cc:1021
idaeim::PVL::Aggregate * PVL_description() const
Produces a PVL description of the observation image data layout for a PDS label.
Definition: Image_Line.cc:1091
bool bad_line() const
Tests if the bad line flag is set.
Definition: Image_Line.cc:381
idaeim::PVL::Aggregate * PVL() const
Produces a PVL rendition of the component.
Definition: Image_Line.cc:1033
u_int_32 sync() const
Gets the extended Sync Element value.
Definition: Image_Line.cc:323
Pixel_type pixel(Index index) const
Gets a pixel value.
Definition: Image_Line.cc:412
static const unsigned int CCD_UNKNOWN
A LUT contains the lookup table used to map 14-bit CCD sensor values to 8-bit image pixel values.
Definition: LUT.hh:68
A Line_Cache manages the data contents for an Image_Line.
Definition: Line_Cache.hh:83
unsigned int u_int_32
U_INT_8_TYPE u_int_8
8-bit unsigned integer type.
Definition: Data_Component.hh:56
PIRL::Data_Block::Index Index
Data_Block element index type.
Definition: Data_Component.hh:95
u_int_16 Pixel_type
The type of a generic pixel value.
Definition: Data_Component.hh:98
University of Arizona.