本文整理汇总了C++中GrayImage::width方法的典型用法代码示例。如果您正苦于以下问题:C++ GrayImage::width方法的具体用法?C++ GrayImage::width怎么用?C++ GrayImage::width使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GrayImage
的用法示例。
在下文中一共展示了GrayImage::width方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BuildPyramid
void GaussianPyramid::BuildPyramid(GrayImage *level0, unsigned nbLevels)
{
GrayImage *pLevel = level0;
_levels.push_back(pLevel);
GaussianFilter gf(_sigma);
// build the nbLevels:
unsigned w = pLevel->width();
unsigned h = pLevel->height();
if (nbLevels != 0) {
for (unsigned int i = 0; i < nbLevels; ++i) { //soc
w = pLevel->width() >> 1;
h = pLevel->height() >> 1;
GrayImage *img = new GrayImage(w, h);
for (unsigned int y = 0; y < h; ++y) {
for (unsigned int x = 0; x < w; ++x) {
float v = gf.getSmoothedPixel<GrayImage>(pLevel, 2 * x, 2 * y);
img->setPixel(x, y, v);
}
}
_levels.push_back(img);
pLevel = img;
}
}
else {
while ((w > 1) && (h > 1)) {
示例2: pixel
float ImagePyramid::pixel(int x, int y, int level)
{
GrayImage *img = _levels[level];
if (0 == level) {
return img->pixel(x, y);
}
unsigned int i = 1 << level;
unsigned int sx = x >> level;
unsigned int sy = y >> level;
if (sx >= img->width())
sx = img->width() - 1;
if (sy >= img->height())
sy = img->height() - 1;
// bilinear interpolation
float A = i * (sx + 1) - x;
float B = x - i * sx;
float C = i * (sy + 1) - y;
float D = y - i * sy;
float P1(0), P2(0);
P1 = A * img->pixel(sx, sy);
if (sx < img->width() - 1) {
if (x % i != 0)
P1 += B * img->pixel(sx + 1, sy);
}
else {
P1 += B * img->pixel(sx, sy);
}
if (sy < img->height() - 1) {
if (y % i != 0) {
P2 = A * img->pixel(sx, sy + 1);
if (sx < img->width() - 1) {
if (x % i != 0)
P2 += B * img->pixel(sx + 1, sy + 1);
}
else {
P2 += B * img->pixel(sx, sy + 1);
}
}
}
else {
P2 = P1;
}
return (1.0f / (float)(1 << (2 * level))) * (C * P1 + D * P2);
}
示例3: downscaled_size
GrayImage
TextLineTracer::downscale(GrayImage const& input, Dpi const& dpi)
{
// Downscale to 200 DPI.
QSize downscaled_size(input.size());
if (dpi.horizontal() < 180 || dpi.horizontal() > 220 || dpi.vertical() < 180 || dpi.vertical() > 220) {
downscaled_size.setWidth(std::max<int>(1, input.width() * 200 / dpi.horizontal()));
downscaled_size.setHeight(std::max<int>(1, input.height() * 200 / dpi.vertical()));
}
return scaleToGray(input, downscaled_size);
}
示例4: calcScale
void
PolynomialSurface::prepareEquationsAndDataPoints(
GrayImage const& image, BinaryImage const& mask,
std::vector<double>& equations,
std::vector<double>& data_points) const
{
int const width = image.width();
int const height = image.height();
double const xscale = calcScale(width);
double const yscale = calcScale(height);
uint8_t const* image_line = image.data();
int const image_bpl = image.stride();
uint32_t const* mask_line = mask.data();
int const mask_wpl = mask.wordsPerLine();
int const last_word_idx = (width - 1) >> 5;
int const last_word_mask = ~uint32_t(0) << (31 - ((width - 1) & 31));
for (int y = 0; y < height; ++y) {
double const y_adjusted = y * yscale;
int idx = 0;
// Full words.
for (; idx < last_word_idx; ++idx) {
processMaskWord(
image_line, mask_line[idx], idx, y,
y_adjusted, xscale, equations, data_points
);
}
// Last word.
processMaskWord(
image_line, mask_line[idx] & last_word_mask,
idx, y, y_adjusted, xscale, equations, data_points
);
image_line += image_bpl;
mask_line += mask_wpl;
}
}
示例5: saveSteerableViewMap
void SteerableViewMap::saveSteerableViewMap() const
{
for (unsigned int i = 0; i <= _nbOrientations; ++i) {
if (_imagesPyramids[i] == 0) {
cerr << "SteerableViewMap warning: orientation " << i <<
" of steerable View Map whas not been computed yet" << endl;
continue;
}
int ow = _imagesPyramids[i]->width(0);
int oh = _imagesPyramids[i]->height(0);
//soc QString base("SteerableViewMap");
string base("SteerableViewMap");
stringstream filename;
for (int j = 0; j < _imagesPyramids[i]->getNumberOfLevels(); ++j) { //soc
float coeff = 1.0f; // 1 / 255.0f; // 100 * 255; // * pow(2, j);
//soc QImage qtmp(ow, oh, QImage::Format_RGB32);
ImBuf *ibuf = IMB_allocImBuf(ow, oh, 32, IB_rect);
int rowbytes = ow * 4;
char *pix;
for (int y = 0; y < oh; ++y) { //soc
for (int x = 0; x < ow; ++x) { //soc
int c = (int)(coeff * _imagesPyramids[i]->pixel(x, y, j));
if (c > 255)
c = 255;
//int c = (int)(_imagesPyramids[i]->pixel(x, y, j));
//soc qtmp.setPixel(x, y, qRgb(c, c, c));
pix = (char *)ibuf->rect + y * rowbytes + x * 4;
pix[0] = pix[1] = pix[2] = c;
}
}
//soc qtmp.save(base+QString::number(i)+"-"+QString::number(j)+".png", "PNG");
filename << base;
filename << i << "-" << j << ".png";
ibuf->ftype = PNG;
IMB_saveiff(ibuf, const_cast<char *>(filename.str().c_str()), 0);
}
#if 0
QString base("SteerableViewMap");
for (unsigned j = 0; j < _imagesPyramids[i]->getNumberOfLevels(); ++j) {
GrayImage *img = _imagesPyramids[i]->getLevel(j);
int ow = img->width();
int oh = img->height();
float coeff = 1.0f; // 100 * 255; // * pow(2, j);
QImage qtmp(ow, oh, 32);
for (unsigned int y = 0; y < oh; ++y) {
for (unsigned int x = 0; x < ow; ++x) {
int c = (int)(coeff * img->pixel(x, y));
if (c > 255)
c = 255;
//int c = (int)(_imagesPyramids[i]->pixel(x, y, j));
qtmp.setPixel(x, y, qRgb(c, c, c));
}
}
qtmp.save(base + QString::number(i) + "-" + QString::number(j) + ".png", "PNG");
}
#endif
}
}