本文整理汇总了C++中Image2D::Width方法的典型用法代码示例。如果您正苦于以下问题:C++ Image2D::Width方法的具体用法?C++ Image2D::Width怎么用?C++ Image2D::Width使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Image2D
的用法示例。
在下文中一共展示了Image2D::Width方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Save
void PngFile::Save(const Image2D &image, const std::string &filename, const ColorMap &colorMap, long double normalizeFactor, long double zeroLevel) throw(IOException)
{
PngFile pngFile(filename, image.Width(), image.Height());
pngFile.BeginWrite();
pngFile.SetFromImage(image, colorMap, normalizeFactor, zeroLevel);
pngFile.Close();
}
示例2: SubtractBackground
void TestSetGenerator::SubtractBackground(Image2D& image)
{
Mask2DPtr zero = Mask2D::CreateSetMaskPtr<false>(image.Width(), image.Height());
LocalFitMethod fittedImage;
fittedImage.SetToWeightedAverage(20, 40, 7.5, 15.0);
Image2DPtr imagePtr = Image2D::MakePtr(image);
TimeFrequencyData data(TimeFrequencyData::AmplitudePart, Polarization::StokesI, imagePtr);
data.SetGlobalMask(zero);
fittedImage.Initialize(data);
for(unsigned i=0;i<fittedImage.TaskCount();++i)
fittedImage.PerformFit(i);
image = Image2D::MakeFromDiff(image, *fittedImage.Background().GetSingleImage());
for(unsigned y=0;y<image.Height();++y) {
for(unsigned x=0;x<image.Width();++x) {
image.AddValue(x, y, 1.0);
}
}
}
示例3: AddBroadbandToTestSet
void TestSetGenerator::AddBroadbandToTestSet(Image2D& image, Mask2D& rfi, long double length, double strength, bool align, enum BroadbandShape shape)
{
size_t frequencyCount = image.Height();
unsigned step = image.Width()/11;
if(align)
{
// see vertevd.h why this is:
unsigned n = (unsigned) floor(0.5 + sqrt(0.25 + 2.0 * frequencyCount));
unsigned affectedAntennas = (unsigned) n*(double)length;
unsigned index = 0;
Logger::Debug << affectedAntennas << " of " << n << " antennas effected." << '\n';
Logger::Debug << "Affected baselines: ";
for(unsigned y=0;y<n;++y)
{
for(unsigned x=y+1;x<n;++x)
{
double a1, a2;
if(x<affectedAntennas) a1=1.0; else a1=0.0;
if(y<affectedAntennas) a2=1.0; else a2=0.0;
if(y<affectedAntennas || x<affectedAntennas)
{
Logger::Debug << x << " x " << y << ", ";
AddRfiPos(image, rfi, 3.0*strength*a1*a2, step*1, 3, index);
AddRfiPos(image, rfi, 2.5*strength*a1*a2, step*2, 3, index);
AddRfiPos(image, rfi, 2.0*strength*a1*a2, step*3, 3, index);
AddRfiPos(image, rfi, 1.8*strength*a1*a2, step*4, 3, index);
AddRfiPos(image, rfi, 1.6*strength*a1*a2, step*5, 3, index);
AddRfiPos(image, rfi, 3.0*strength*a1*a2, step*6, 1, index);
AddRfiPos(image, rfi, 2.5*strength*a1*a2, step*7, 1, index);
AddRfiPos(image, rfi, 2.0*strength*a1*a2, step*8, 1, index);
AddRfiPos(image, rfi, 1.8*strength*a1*a2, step*9, 1, index);
AddRfiPos(image, rfi, 1.6*strength*a1*a2, step*10, 1, index);
}
++index;
}
}
Logger::Debug << ".\n";
} else {
unsigned fStart = (unsigned) ((0.5 - length/2.0) * frequencyCount);
unsigned fEnd = (unsigned) ((0.5 + length/2.0) * frequencyCount);
AddBroadbandLinePos(image, rfi, 3.0*strength, step*1, 3, fStart, fEnd, shape);
AddBroadbandLinePos(image, rfi, 2.5*strength, step*2, 3, fStart, fEnd, shape);
AddBroadbandLinePos(image, rfi, 2.0*strength, step*3, 3, fStart, fEnd, shape);
AddBroadbandLinePos(image, rfi, 1.8*strength, step*4, 3, fStart, fEnd, shape);
AddBroadbandLinePos(image, rfi, 1.6*strength, step*5, 3, fStart, fEnd, shape);
AddBroadbandLinePos(image, rfi, 3.0*strength, step*6, 1, fStart, fEnd, shape);
AddBroadbandLinePos(image, rfi, 2.5*strength, step*7, 1, fStart, fEnd, shape);
AddBroadbandLinePos(image, rfi, 2.0*strength, step*8, 1, fStart, fEnd, shape);
AddBroadbandLinePos(image, rfi, 1.8*strength, step*9, 1, fStart, fEnd, shape);
AddBroadbandLinePos(image, rfi, 1.6*strength, step*10, 1, fStart, fEnd, shape);
}
}
示例4: AddVarBroadbandToTestSet
void TestSetGenerator::AddVarBroadbandToTestSet(Image2D& image, Mask2D& rfi)
{
// The "randomness" should be reproducable randomness, so calling
// the random number generator to generate the numbers is not a good
// idea.
unsigned step = image.Width()/11;
AddBroadbandLine(image, rfi, 3.0, step*1, 3, 0.937071,0.0185952);
AddBroadbandLine(image, rfi, 2.5, step*2, 3, 0.638442,0.327689);
AddBroadbandLine(image, rfi, 2.0, step*3, 3, 0.859308,0.0211675);
AddBroadbandLine(image, rfi, 1.8, step*4, 3, 0.418327,0.324842);
AddBroadbandLine(image, rfi, 1.6, step*5, 3, 0.842374,0.105613);
AddBroadbandLine(image, rfi, 3.0, step*6, 1, 0.704607,0.163653);
AddBroadbandLine(image, rfi, 2.5, step*7, 1, 0.777955,0.0925143);
AddBroadbandLine(image, rfi, 2.0, step*8, 1, 0.288418,0.222322);
AddBroadbandLine(image, rfi, 1.8, step*9, 1, 0.892462,0.0381083);
AddBroadbandLine(image, rfi, 1.6, step*10, 1, 0.444377,0.240526);
}
示例5: AddSlewedBroadbandToTestSet
void TestSetGenerator::AddSlewedBroadbandToTestSet(Image2D& image, Mask2D& rfi, long double length, double strength, double slewrate, enum BroadbandShape shape)
{
size_t frequencyCount = image.Height();
unsigned step = image.Width()/11;
unsigned fStart = (unsigned) ((0.5 - length/2.0) * frequencyCount);
unsigned fEnd = (unsigned) ((0.5 + length/2.0) * frequencyCount);
AddSlewedBroadbandLinePos(image, rfi, 3.0*strength, slewrate, step*1, 3, fStart, fEnd, shape);
AddSlewedBroadbandLinePos(image, rfi, 2.5*strength, slewrate, step*2, 3, fStart, fEnd, shape);
AddSlewedBroadbandLinePos(image, rfi, 2.0*strength, slewrate, step*3, 3, fStart, fEnd, shape);
AddSlewedBroadbandLinePos(image, rfi, 1.8*strength, slewrate, step*4, 3, fStart, fEnd, shape);
AddSlewedBroadbandLinePos(image, rfi, 1.6*strength, slewrate, step*5, 3, fStart, fEnd, shape);
AddSlewedBroadbandLinePos(image, rfi, 3.0*strength, slewrate, step*6, 1, fStart, fEnd, shape);
AddSlewedBroadbandLinePos(image, rfi, 2.5*strength, slewrate, step*7, 1, fStart, fEnd, shape);
AddSlewedBroadbandLinePos(image, rfi, 2.0*strength, slewrate, step*8, 1, fStart, fEnd, shape);
AddSlewedBroadbandLinePos(image, rfi, 1.8*strength, slewrate, step*9, 1, fStart, fEnd, shape);
AddSlewedBroadbandLinePos(image, rfi, 1.6*strength, slewrate, step*10, 1, fStart, fEnd, shape);
}
示例6: SetModelData
void TestSetGenerator::SetModelData(Image2D& image, Mask2D& rfi, unsigned sources)
{
class Model model;
if(sources>=5) {
model.AddSource(0.1,0.1,0.5);
model.AddSource(0.1,0.0,0.35);
model.AddSource(.101,0.001,0.45);
model.AddSource(1.0,0.0,1.0);
model.AddSource(4.0,3.0,0.9);
} else {
if(sources>=1)
model.AddSource(0.1,0.1,0.7);
if(sources>=2)
model.AddSource(0.1,0.0,0.5);
if(sources>=3)
model.AddSource(1.0,0.0,1.0);
}
WSRTObservatorium wsrt(size_t(0), size_t(1));
std::pair<TimeFrequencyData,TimeFrequencyMetaDataCPtr> data =
model.SimulateObservation(wsrt, 0.05, 0.05, 0, 1);
image = *data.first.GetRealPart();
rfi = Mask2D::MakeSetMask<false>(image.Width(), image.Height());
}
示例7: 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);
//.........这里部分代码省略.........
示例8: 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;
//.........这里部分代码省略.........