本文整理汇总了C++中Image2D::Value方法的典型用法代码示例。如果您正苦于以下问题:C++ Image2D::Value方法的具体用法?C++ Image2D::Value怎么用?C++ Image2D::Value使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Image2D
的用法示例。
在下文中一共展示了Image2D::Value方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Save
void PngFile::Save(const Image2D &image, const ColorMap &colorMap) throw(IOException)
{
long double normalizeFactor = image.GetMaxMinNormalizationFactor();
png_bytep *row_pointers = RowPointers();
for(unsigned long y=0;y<image.Height();++y) {
for(unsigned long x=0;x<image.Width();++x) {
int xa = x * PixelSize();
row_pointers[y][xa]=colorMap.ValueToColorR(image.Value(x, y) * normalizeFactor);
row_pointers[y][xa+1]=colorMap.ValueToColorG(image.Value(x, y) * normalizeFactor);
row_pointers[y][xa+2]=colorMap.ValueToColorB(image.Value(x, y) * normalizeFactor);
row_pointers[y][xa+3]=colorMap.ValueToColorA(image.Value(x, y) * normalizeFactor);
}
}
}
示例2: AddBaseline
void ImageTile::AddBaseline(Image2D &dest, double sign)
{
// Add or subtract baseline
for(unsigned channel = 0;channel<_channelCount;++channel) {
for(unsigned scan = 0;scan<_scanCount;++scan) {
long double val = dest.Value(scan+_scanOffset, channel+_channelOffset);
val += sign * EvaluateBaselineFunction(scan, channel);
SetValueAt(dest, channel, scan, val);
}
}
}
示例3: MakeTestSet
Image2D TestSetGenerator::MakeTestSet(int number, Mask2D& rfi, unsigned width, unsigned height, int gaussianNoise)
{
Image2D image;
switch(number)
{
case 0: // Image of all zero's
return Image2D::MakeZeroImage(width, height);
case 1: // Image of all ones
image = Image2D::MakeUnsetImage(width, height);
image.SetAll(1.0);
break;
case 2: // Noise
return MakeNoise(width, height, gaussianNoise);
case 3: { // Several broadband lines
image = MakeNoise(width, height, gaussianNoise);
AddBroadbandToTestSet(image, rfi, 1.0);
} break;
case 4: { // Several broadband lines
image = MakeNoise(width, height, gaussianNoise);
AddBroadbandToTestSet(image, rfi, 0.5);
} break;
case 5: { // Several broadband lines of random length
image = MakeNoise(width, height, gaussianNoise);
AddVarBroadbandToTestSet(image, rfi);
} break;
case 6: { // Different broadband lines + low freq background
image = MakeNoise(width, height, gaussianNoise);
AddVarBroadbandToTestSet(image, rfi);
for(unsigned y=0;y<image.Height();++y) {
for(unsigned x=0;x<image.Width();++x) {
image.AddValue(x, y, sinn(num_t(x)*M_PIn*5.0 / image.Width()) + 0.1);
}
}
} break;
case 7: { // Different broadband lines + high freq background
image = MakeNoise(width, height, gaussianNoise);
for(unsigned y=0;y<image.Height();++y) {
for(unsigned x=0;x<image.Width();++x) {
image.AddValue(x, y, sinn((long double) (x+y*0.1)*M_PIn*5.0L / image.Width() + 0.1));
image.AddValue(x, y, sinn((long double) (x+pown(y, 1.1))*M_PIn*50.0L / image.Width() + 0.1));
}
}
AddVarBroadbandToTestSet(image, rfi);
for(unsigned y=0;y<image.Height();++y) {
for(unsigned x=0;x<image.Width();++x) {
image.AddValue(x, y, 1.0);
}
}
} break;
case 8: { // Different droadband lines + smoothed&subtracted high freq background
image = MakeNoise(width, height, gaussianNoise);
for(unsigned y=0;y<image.Height();++y) {
for(unsigned x=0;x<image.Width();++x) {
image.AddValue(x, y, sinn((num_t) (x+y*0.1)*M_PIn*5.0 / image.Width() + 0.1));
image.AddValue(x, y, sinn((num_t) (x+pown(y, 1.1))*M_PIn*50.0 / image.Width() + 0.1));
}
}
SubtractBackground(image);
AddVarBroadbandToTestSet(image, rfi);
} break;
case 9: { //FFT of 7
image = MakeTestSet(7, rfi, width, height);
Image2D copy(image);
FFTTools::CreateHorizontalFFTImage(image, copy, false);
for(unsigned y=0;y<rfi.Height();++y) {
for(unsigned x=0;x<rfi.Width();++x) {
image.SetValue(x, y, image.Value(x, y) / sqrtn(image.Width()));
}
}
} break;
case 10: { // Identity matrix
image = Image2D::MakeZeroImage(width, height);
unsigned min = width < height ? width : height;
for(unsigned i=0;i<min;++i) {
image.SetValue(i, i, 1.0);
rfi.SetValue(i, i, true);
}
} break;
case 11: { // FFT of identity matrix
image = MakeTestSet(10, rfi, width, height);
Image2D copy(image);
FFTTools::CreateHorizontalFFTImage(image, copy, false);
for(unsigned y=0;y<rfi.Height();++y) {
for(unsigned x=0;x<rfi.Width();++x) {
image.SetValue(x, y, image.Value(x, y) / sqrtn(width));
}
}
} break;
case 12: { // Broadband contaminating all channels
image = MakeNoise(width, height, gaussianNoise);
for(unsigned y=0;y<image.Height();++y) {
for(unsigned x=0;x<image.Width();++x) {
image.AddValue(x, y, sinn((num_t) (x+y*0.1)*M_PIn*5.0 / image.Width() + 0.1));
image.AddValue(x, y, sinn((num_t) (x+powl(y, 1.1))*M_PIn*50.0 / image.Width() + 0.1));
}
}
AddBroadbandToTestSet(image, rfi, 1.0);
} break;
case 13: { // Model of three point sources with broadband RFI
SetModelData(image, rfi, 3);
//.........这里部分代码省略.........
示例4: main
int main(int argc, char *argv[])
{
int pindex = 1;
// parameters
bool useSpectrum = true;
bool colormap = false;
int removeNoiseImages = 0;
bool fft = false;
enum ScaleMethod { MaximumContrast, Constant } scaleMethod = MaximumContrast;
long double scaleValue = 1.0;
std::string subtractFile, outputFitsFile, outputPngFile;
bool subtract = false, redblue = false, rms = false, individualMaximization = false, displayMax = false, singleImage = false;
bool window = false, cutWindow = false, saveFits = false, savePng = false;
size_t windowX = 0, windowY = 0, windowWidth = 0, windowHeight = 0;
size_t cutWindowX = 0, cutWindowY = 0, cutWindowWidth = 0, cutWindowHeight = 0;
size_t singleImageIndex = 0;
while(pindex < argc && argv[pindex][0] == '-') {
string parameter = argv[pindex]+1;
if(parameter == "s") { useSpectrum = true; }
else if(parameter == "c") { useSpectrum = false; }
else if(parameter == "d") { ++pindex; subtractFile = argv[pindex]; subtract=true; }
else if(parameter == "fft") { fft = true; }
else if(parameter == "fi") { individualMaximization = true; }
else if(parameter == "fits") {
saveFits = true;
++pindex; outputFitsFile = argv[pindex];
}
else if(parameter == "fm") { scaleMethod = MaximumContrast; }
else if(parameter == "fv") { scaleMethod = Constant; ++pindex; scaleValue = atof(argv[pindex]); }
else if(parameter == "m") { colormap = true; }
else if(parameter == "max") { displayMax=true; }
else if(parameter == "png")
{
savePng = true;
++pindex; outputPngFile = argv[pindex];
}
else if(parameter == "r") { ++pindex; removeNoiseImages = atoi(argv[pindex]); }
else if(parameter == "rb") { redblue=true; }
else if(parameter == "rms") { rms=true; }
else if(parameter == "si")
{
singleImage = true;
++pindex; singleImageIndex = atoi(argv[pindex]);
}
else if(parameter == "w") {
window = true;
++pindex; windowX = atoi(argv[pindex]);
++pindex; windowY = atoi(argv[pindex]);
++pindex; windowWidth = atoi(argv[pindex]);
++pindex; windowHeight = atoi(argv[pindex]);
}
else if(parameter == "wc") {
cutWindow = true;
++pindex; cutWindowX = atoi(argv[pindex]);
++pindex; cutWindowY = atoi(argv[pindex]);
++pindex; cutWindowWidth = atoi(argv[pindex]);
++pindex; cutWindowHeight = atoi(argv[pindex]);
}
else {
cerr << "Unknown parameter: -" << parameter << endl;
return -1;
}
++pindex;
}
if(argc-pindex < 1) {
cerr << "Usage: \n\t" << argv[0] << " [options] <input fits file>\n"
"\toptions:\n"
"\t-d <fitsfile> subtract the file from the image\n"
"\t-fft perform fft before combining\n"
"\t-fi maximize each individual image before summing\n"
"\t-fits <file> store in fits file (does not preserve the headers)\n"
"\t-fm scale colors for maximum contrast, upper 0.02% of the data will be oversaturated (default)\n"
"\t-fv <value> scale so that <value> flux is full brightness\n"
"\t-m add colormap to image\n"
"\t-max display maximum of each image\n"
"\t-png <file> save as png file\n"
"\t-rb don't use frequency colored, but use red/blue map for positive/negative values\n"
"\t-rms calculate and show the rms of the upperleft 10% data\n"
"\t-s use spectrum (default)\n"
"\t-si <index> select single image from each fits file\n"
"\t-c use color circle\n"
"\t-w <x> <y> <width> <height> select a window of each frame only\n"
"\t-wc <x> <y> <width> <height> cut a window in each frame\n";
return -1;
}
Image2D *red = 0;
Image2D *green = 0;
Image2D *blue = 0;
Image2D *mono = 0;
long double totalRed = 0.0, totalGreen = 0.0, totalBlue = 0.0;
unsigned addedCount = 0;
size_t inputCount = argc-pindex;
for(unsigned inputIndex=pindex;inputIndex<(unsigned) argc;++inputIndex)
{
cout << "Opening " << argv[inputIndex] << "..." << endl;
//.........这里部分代码省略.........