00001 #ifndef Impala_Core_Array_GetRgbPixels_h
00002 #define Impala_Core_Array_GetRgbPixels_h
00003
00004 #include <string>
00005 #include "Core/Array/Pattern/PatRgbOp.h"
00006 #include "Core/Array/Trait/RgbLabel.h"
00007 #include "Core/Array/Trait/RgbLabel60.h"
00008 #include "Core/Array/Trait/RgbLabelN.h"
00009 #include "Core/Array/Trait/RgbBinary.h"
00010 #include "Core/Array/Trait/RgbDirect.h"
00011 #include "Core/Array/Trait/RgbStretch.h"
00012 #include "Core/Array/Trait/RgbLogMag.h"
00013 #include "Core/Geometry/GeoIntType.h"
00014 #include "Core/Array/PixMin.h"
00015 #include "Core/Array/PixMax.h"
00016 #include "Core/Array/PixStat.h"
00017 #include "Core/Array/PixMinMax.h"
00018 #include "Core/Array/Element/E1Min.h"
00019 #include "Core/Array/Element/E1Max.h"
00020
00021 #undef max
00022
00023 namespace Impala
00024 {
00025 namespace Core
00026 {
00027 namespace Array
00028 {
00029
00030
00031 template<class ArrayT>
00032 inline void
00033 GetRgbPixels(ArrayT* src, UInt8* pixels, std::string displayMode,
00034 int resWidth = -1, int resHeight = -1,
00035 Geometry::GeoIntType gi = Geometry::NEAREST)
00036 {
00037 typedef typename ArrayT::ArithType ArithT;
00038
00039 if (displayMode == std::string("Stretch"))
00040 {
00041 ArithT minVal, maxVal;
00042
00043 minVal = PixMin(src);
00044 maxVal = PixMax(src);
00045 Real64 lowVal = Element::E1Min(minVal);
00046 Real64 highVal = Element::E1Max(maxVal);
00047
00048 Trait::RgbStretch<ArithT> rgbOpStretch(lowVal, highVal);
00049 Pattern::PatRgbOp(src, pixels, resWidth, resHeight, gi, rgbOpStretch);
00050 }
00051 else if (displayMode == std::string("Sigma"))
00052 {
00053 ArithT minVal, maxVal, mean, stdev;
00054 PixStat(src, &minVal, &maxVal, &mean, &stdev);
00055
00056 Real64 lowVal = Element::E1Max(mean) - Element::E1Max(stdev) * 5;
00057 Real64 highVal = Element::E1Max(mean) + Element::E1Max(stdev) * 5;
00058 std::cout << "min " << minVal << " max " << maxVal << " mean " << mean
00059 << " stdev " << stdev
00060 << " stretch " << lowVal << " - " << highVal << std::endl;
00061 Trait::RgbStretchClip<ArithT> rgbOpStretch(lowVal, highVal);
00062 Pattern::PatRgbOp(src, pixels, resWidth, resHeight, gi, rgbOpStretch);
00063 }
00064 else if (displayMode == std::string("StrMax"))
00065 {
00066 ArithT minVal, maxVal;
00067 PixMinMax(src, &minVal, &maxVal);
00068 Real64 lowVal = Element::E1Min(minVal);
00069 Real64 highVal = Element::E1Max(maxVal) / 4;
00070 Trait::RgbStretchClip<ArithT> rgbOpStretch(lowVal, highVal);
00071 Pattern::PatRgbOp(src, pixels, resWidth, resHeight, gi, rgbOpStretch);
00072 }
00073 else if (displayMode == std::string("LogMagnitude"))
00074 {
00075 ArithT minVal, maxVal;
00076 PixMinMax(src, &minVal, &maxVal);
00077 Real64 lowVal = Element::E1Min(minVal);
00078 Real64 highVal = Element::E1Max(maxVal);
00079 Trait::RgbLogMag<ArithT> rgbOpLogMag(lowVal, highVal);
00080 Pattern::PatRgbOp(src, pixels, resWidth, resHeight, gi, rgbOpLogMag);
00081 }
00082 else if (displayMode == std::string("Binary"))
00083 {
00084 Trait::RgbBinary<ArithT> rgbOpBinary;
00085 Pattern::PatRgbOp(src, pixels, resWidth, resHeight, gi, rgbOpBinary);
00086 }
00087 else if (displayMode == std::string("Label"))
00088 {
00089 Trait::RgbLabel<ArithT> rgbOpLabel;
00090 Pattern::PatRgbOp(src, pixels, resWidth, resHeight, gi, rgbOpLabel);
00091 }
00092 else if (displayMode == std::string("Label60"))
00093 {
00094 Trait::RgbLabel60<ArithT> rgbOpLabel60;
00095 Pattern::PatRgbOp(src, pixels, resWidth, resHeight, gi, rgbOpLabel60);
00096 }
00097 else if (displayMode == std::string("LabelN"))
00098 {
00099 Trait::RgbLabelN<ArithT> rgbOpLabelN;
00100 Pattern::PatRgbOp(src, pixels, resWidth, resHeight, gi, rgbOpLabelN);
00101 }
00102 else
00103 {
00104
00105 Trait::RgbDirectNC<ArithT> rgbOpDirect;
00106 Pattern::PatRgbOp(src, pixels, resWidth, resHeight, gi, rgbOpDirect);
00107 }
00108 }
00109
00110 template<class ArrayT>
00111 inline void
00112 GetRgbPixelsLM(ArrayT* src, UInt8* pixels, Real64 logScale,
00113 int resWidth = -1, int resHeight = -1,
00114 Geometry::GeoIntType gi = Geometry::NEAREST)
00115 {
00116 typedef typename ArrayT::ArithType ArithT;
00117
00118 ArithT val;
00119 val = PixMin(src);
00120 Real64 lowVal = Element::E1Min(val);
00121 val = PixMax(src);
00122 Real64 highVal = Element::E1Max(val);
00123 Trait::RgbLogMag<ArithT> rgbOpLogMag(lowVal, highVal, logScale);
00124 Pattern::PatRgbOp(src, pixels, resWidth, resHeight, gi, rgbOpLogMag);
00125 }
00126
00127 template<class ArrayT>
00128 inline void
00129 GetRgbPixelsSt(ArrayT* src, UInt8* pixels, Real64 lowVal, Real64 highVal,
00130 int resWidth = -1, int resHeight = -1,
00131 Geometry::GeoIntType gi = Geometry::NEAREST)
00132 {
00133 typedef typename ArrayT::ArithType ArithT;
00134
00135 Trait::RgbStretchClip<ArithT> rgbOpStretch(lowVal, highVal);
00136 Pattern::PatRgbOp(src, pixels, resWidth, resHeight, gi, rgbOpStretch);
00137 }
00138
00139 }
00140 }
00141 }
00142
00143 #endif