本文整理汇总了C++中Image2D类的典型用法代码示例。如果您正苦于以下问题:C++ Image2D类的具体用法?C++ Image2D怎么用?C++ Image2D使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Image2D类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: read
void AbstractFramebuffer::read(const Range2Di& rectangle, Image2D& image) {
bindInternal(FramebufferTarget::Read);
const std::size_t dataSize = image.dataSize(rectangle.size());
char* const data = new char[dataSize];
(Context::current()->state().framebuffer->readImplementation)(rectangle, image.format(), image.type(), dataSize, data);
image.setData(image.format(), image.type(), rectangle.size(), data);
}
示例2: throw
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();
}
示例3:
Image2D::Image2D(Image2D const& _cpy)
{
SetText(_cpy.GetText());
m_fg = _cpy.GetForegroundColor();
m_bg = _cpy.GetBackgroundColor();
m_width = _cpy.GetWidth();
m_height = _cpy.GetHeight();
}
示例4: a
void ImageTest::release() {
unsigned char data[] = {'c', 'a', 'f', 'e'};
Image2D a(ColorFormat::Red, ColorType::UnsignedByte, {1, 4}, data);
const unsigned char* const pointer = a.release();
CORRADE_COMPARE(pointer, data);
CORRADE_COMPARE(a.data(), nullptr);
CORRADE_COMPARE(a.size(), Vector2i());
}
示例5: MakeGaussianData
Image2D TestSetGenerator::MakeGaussianData(unsigned width, unsigned height)
{
Image2D image = Image2D::MakeUnsetImage(width, height);
for(unsigned y=0;y<height;++y) {
for(unsigned x=0;x<width;++x) {
image.SetValue(x, y, RNG::Gaussian());
}
}
return image;
}
示例6: 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);
}
}
示例7: screenshot
bool screenshot(PluginManager::Manager<Trade::AbstractImageConverter>& manager, GL::AbstractFramebuffer& framebuffer, const PixelFormat format, const std::string& filename) {
Containers::Pointer<Trade::AbstractImageConverter> converter;
if(!(converter = manager.loadAndInstantiate("AnyImageConverter")))
return false;
Image2D image = framebuffer.read(framebuffer.viewport(), {format});
if(!converter->exportToFile(image, filename))
return false;
Debug{} << "DebugTools::screenshot(): saved a" << format << "image of size" << image.size() << "to" << filename;
return true;
}
示例8: sampleRFIDistribution
Image2D TestSetGenerator::sampleRFIDistribution(unsigned width, unsigned height, double ig_over_rsq)
{
Image2D image = Image2D::MakeUnsetImage(width, height);
const double sigma = 1.0;
for(size_t f=0; f<height;++f) {
for(size_t t=0; t<width;++t) {
image.SetValue(t, f, Rand(Gaussian)*sigma + ig_over_rsq / RNG::Uniform());
}
}
return image;
}
示例9: AddBroadbandLine
void TestSetGenerator::AddBroadbandLine(Image2D& data, Mask2D& rfi, double lineStrength, size_t startTime, size_t duration, double frequencyRatio, double frequencyOffsetRatio)
{
size_t frequencyCount = data.Height();
unsigned fStart = (size_t) (frequencyOffsetRatio * frequencyCount);
unsigned fEnd = (size_t) ((frequencyOffsetRatio + frequencyRatio) * frequencyCount);
AddBroadbandLinePos(data, rfi, lineStrength, startTime, duration, fStart, fEnd, UniformShape);
}
示例10: Raw2D2Image2D
void * Raw2D2Image2D(Raw2D &src,long long type)
{
PIXTYPE *data= new PIXTYPE[src.size()];
if (type==1)
{
unsigned char* datSrc = new unsigned char [src.size()];//(unsigned char*)(src.data);
//PIXTYPE *data= new PIXTYPE[src.GetLength()];
for (long long i=0;i<src.size();i++)
{
datSrc[i]=(unsigned char)src.getXY(i);
}
//void * ret= (void *)datSrc;
Image2D * ret = new Image2D(src.getXsize(),src.getYsize(),type);
memcpy(ret->data,datSrc,ret->GetLength());
unsigned char *dat =(unsigned char*)ret->data;
void *res =(void *)ret;
return res;
}
else if (type == 2)
{
unsigned short * datSrc = new unsigned short [src.size()];//(unsigned short *)(src.data);
//PIXTYPE *data= new PIXTYPE[src.GetLength()];
for (long long i=0;i<src.size();i++)
{
datSrc[i]=src.getXY(i);
}
void * ret=(void *)datSrc;
return datSrc;
}
else
{
float* datSrc = new float [src.size()]; //(short*)(src.data);
for (long long i=0;i<src.size();i++)
{
datSrc[i]=src.getXY(i);
}
void *ret =(void *)datSrc;
return datSrc;
}
}
示例11: RecenterImage
void RecenterImage(Image2D &image)
{
IppStatus status;
Ipp32f minval = 0, maxval = 0;
status = ippiMinMax_32f_C1R(image.get_image2D(), image.get_stepsize(), image.get_ROIfull(),
&minval, &maxval);
status = ippiAddC_32f_C1IR(-minval, image.get_image2D(), image.get_stepsize(), image.get_ROIfull());
status = ippiMulC_32f_C1IR(100 / (maxval-minval), image.get_image2D(), image.get_stepsize(), image.get_ROIfull());
}
示例12: AddRfiPos
void TestSetGenerator::AddRfiPos(Image2D& data, Mask2D& rfi, double lineStrength, size_t startTime, size_t duration, unsigned frequencyPos)
{
for(size_t t=startTime;t<startTime+duration;++t) {
data.AddValue(t, frequencyPos, lineStrength);
if(lineStrength > 0)
rfi.SetValue(t, frequencyPos, true);
}
}
示例13: data
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);
}
}
}
示例14: fill_data
void fill_data( Image2D& _data )
{
double* data;
CALuint pitch;
unsigned size;
data = (double*)_queue.mapMemObject(_data,pitch);
size = 2*_data.getWidth()*_data.getHeight();
for(unsigned i=0;i<size;i+=2) {
*(data + 0) = i+1;
*(data + 1) = i+1;
data+=2;
}
_queue.unmapMemObject(_data);
}
示例15: 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);
}