当前位置: 首页>>代码示例>>C++>>正文


C++ Image2D::SaveToFitsFile方法代码示例

本文整理汇总了C++中Image2D::SaveToFitsFile方法的典型用法代码示例。如果您正苦于以下问题:C++ Image2D::SaveToFitsFile方法的具体用法?C++ Image2D::SaveToFitsFile怎么用?C++ Image2D::SaveToFitsFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Image2D的用法示例。


在下文中一共展示了Image2D::SaveToFitsFile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main


//.........这里部分代码省略.........
								blue->AddValue(x, y, value/(-max)); 
						}
						else {
							if(value < 0.0) value = 0.0;
							value /= max;
							if(colormap && (y < 96 && y >= 32 && x < images*8)) { 
								if(x >= i*8 && x < i*8+8) {
									red->SetValue(x, y, r * images);
									green->SetValue(x, y, g * images);
									blue->SetValue(x, y, b * images);
								}
							} else {
								red->AddValue(x, y, r * value);
								green->AddValue(x, y, g * value);
								blue->AddValue(x, y, b * value);
							}
						}
					}
				}
				++addedCount; 
				delete image;
			}
		}
		
		if(subtract) {
			subtractFits->Close();
			delete subtractFits;
		}
	}
		
	cout << "Scaling to ordinary units..." << endl;
	for(unsigned y=0;y<red->Height();++y) {
		for(unsigned x=0;x<red->Width();++x) {
			red->SetValue(x, y, red->Value(x, y) / addedCount);
			blue->SetValue(x, y, blue->Value(x, y) / addedCount);
			green->SetValue(x, y, green->Value(x, y) / addedCount);
			mono->SetValue(x, y, mono->Value(x, y) / addedCount);
		}
	}

	if(rms) {
		ReportRMS(mono);
	}
	
	if(saveFits)
	{
		cout << "Saving fits file..." << endl;
		mono->SaveToFitsFile(outputFitsFile);
	}

	if(savePng)
	{
		cout << "Normalizing..." << endl;
		long double maxRed, maxGreen, maxBlue;
		switch(scaleMethod) {
			default:
			case MaximumContrast:
				maxRed = red->GetTresholdForCountAbove(red->Width() * red->Height() / 5000);
				maxGreen = green->GetTresholdForCountAbove(green->Width() * green->Height() / 5000);
				maxBlue = blue->GetTresholdForCountAbove(blue->Width() * blue->Height() / 5000);
			break;
			case Constant:
				maxRed = scaleValue;
				maxGreen = scaleValue * totalGreen / totalRed;
				maxBlue = scaleValue * totalBlue / totalRed;
			break; 
		}
		if(maxRed <= 0.0) maxRed = 1.0;
		if(maxGreen <= 0.0) maxGreen = 1.0;
		if(maxBlue <= 0.0) maxBlue = 1.0;
		cout << "Contrast stretch value for red: " << maxRed << endl; 
		
		PngFile file(outputPngFile, red->Width(), red->Height());
		file.BeginWrite();

		cout << "Writing " << outputPngFile << "..." << endl;
		for(unsigned y=0;y<red->Height();++y)
		{
			for(unsigned x=0;x<red->Width();++x)	
			{
				unsigned
					r = (unsigned) ((red->Value(x, y) / maxRed) * 255.0),
					g = (unsigned) ((green->Value(x, y) / maxGreen) * 255.0),
					b = (unsigned) ((blue->Value(x, y) / maxBlue) * 255.0);
				if(r > 255) r = 255;
				if(g > 255) g = 255;
				if(b > 255) b = 255;
				file.PlotDatapoint(x, red->Height() - 1 - y, r, g, b, 255);
			}
		}
		file.Close();
	}
	
	delete red;
	delete green;
	delete blue;
	delete mono;

  return EXIT_SUCCESS;
}
开发者ID:jjdmol,项目名称:LOFAR,代码行数:101,代码来源:colormapper.cpp


注:本文中的Image2D::SaveToFitsFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。