Пример #1
0
// erode foreground and background regions to increase the size of unknown region
static void erodeFB(cv::Mat &_trimap, int r)
{
    cv::Mat_<uchar> &trimap = (cv::Mat_<uchar>&)_trimap;

    int w = trimap.cols;
    int h = trimap.rows;

    cv::Mat_<uchar> foreground(trimap.size(), (uchar)0);
    cv::Mat_<uchar> background(trimap.size(), (uchar)0);

    for (int y = 0; y < h; ++y)
        for (int x = 0; x < w; ++x)
        {
            if (trimap(y, x) == 0)
                background(y, x) = 1;
            else if (trimap(y, x) == 255)
                foreground(y, x) = 1;
        }


    cv::Mat kernel = cv::getStructuringElement(cv::MORPH_ELLIPSE, cv::Size(r, r));

    cv::erode(background, background, kernel);
    cv::erode(foreground, foreground, kernel);

    for (int y = 0; y < h; ++y)
        for (int x = 0; x < w; ++x)
        {
            if (background(y, x) == 0 && foreground(y, x) == 0)
                trimap(y, x) = 128;
        }
}
Пример #2
0
static void globalMattingHelper(cv::Mat _image, cv::Mat _trimap, cv::Mat &_foreground, cv::Mat &_alpha, cv::Mat &_conf)
{
    const cv::Mat_<cv::Vec3b> &image = (const cv::Mat_<cv::Vec3b>&)_image;
    const cv::Mat_<uchar> &trimap = (const cv::Mat_<uchar>&)_trimap;

    std::vector<cv::Point> foregroundBoundary = findBoundaryPixels(trimap, 255, 128);
    std::vector<cv::Point> backgroundBoundary = findBoundaryPixels(trimap, 0, 128);

    int n = (int)(foregroundBoundary.size() + backgroundBoundary.size());
    for (int i = 0; i < n; ++i)
    {
        int x = rand() % trimap.cols;
        int y = rand() % trimap.rows;

        if (trimap(y, x) == 0)
            backgroundBoundary.push_back(cv::Point(x, y));
        else if (trimap(y, x) == 255)
            foregroundBoundary.push_back(cv::Point(x, y));
    }

    std::sort(foregroundBoundary.begin(), foregroundBoundary.end(), IntensityComp(image));
    std::sort(backgroundBoundary.begin(), backgroundBoundary.end(), IntensityComp(image));

    std::vector<std::vector<Sample> > samples;
    calculateAlphaPatchMatch(image, trimap, foregroundBoundary, backgroundBoundary, samples);

    _foreground.create(image.size(), CV_8UC3);
    _alpha.create(image.size(), CV_8UC1);
    _conf.create(image.size(), CV_8UC1);

    cv::Mat_<cv::Vec3b> &foreground = (cv::Mat_<cv::Vec3b>&)_foreground;
    cv::Mat_<uchar> &alpha = (cv::Mat_<uchar>&)_alpha;
    cv::Mat_<uchar> &conf = (cv::Mat_<uchar>&)_conf;

    for (int y = 0; y < alpha.rows; ++y)
        for (int x = 0; x < alpha.cols; ++x)
        {
            switch (trimap(y, x))
            {
                case 0:
                    alpha(y, x) = 0;
                    conf(y, x) = 255;
                    foreground(y, x) = 0;
                    break;
                case 128:
                {
                    alpha(y, x) = 255 * samples[y][x].alpha;
                    conf(y, x) = 255 * exp(-samples[y][x].cost / 6);
                    cv::Point p = foregroundBoundary[samples[y][x].fi];
                    foreground(y, x) = image(p.y, p.x);
                    break;
                }
                case 255:
                    alpha(y, x) = 255;
                    conf(y, x) = 255;
                    foreground(y, x) = image(y, x);
                    break;
            }
        }
}
Пример #3
0
unsigned long MSTableColumn::cellForeground(unsigned row_)        
{
  if (table()!=0)
   {
     if (table()->foregroundColors().length()==0) return foreground();
     else return table()->foregroundColors()(row_%table()->foregroundColors().length());
   }
  else return foreground();
}
Пример #4
0
void MSWidget::foreground(unsigned long pixel_)
{ 
  if (pixel_!=foreground()) 
   {
     unsigned long old=foreground();
     _fg=pixel_;
     updateForeground(old);
   }
}
Пример #5
0
void MSTextRect::foreground(unsigned long pixel_)
{
  if (foreground()!=pixel_)
   {
     unsigned long oldfg=_fg;     
     _fg=pixel_;
     textMSGC().foreground(foreground());
     updateForeground(oldfg);     
   }
}
Пример #6
0
void bargraph_t::refresh(SDL_Rect *r)
{
	if(!_enabled)
	{
		clear();
		return;
	}
	float v = _value;
	int red, green, blue;
	if(v > 1.0f)
	{
		blue = 50 + (v - 1.0f) * 512;
		if(_redmax)
		{
			red = 255;
			green = blue / 2;
		}
		else
		{
			green = 255;
			red = blue / 2;
		}
		v = 1.0f;
	}
	else
	{
		if(_redmax)
		{
			red = (int)(v * 300.0);
			green = (int)((1.0 - v) * 400.0);
		}
		else
		{
			red = (int)((1.0 - v) * 300.0);
			green = (int)(v * 400.0);
		}
		blue = 50;
	}
	if(green > 180)
		green = 180;
	if(red > 230)
		red = 230;
	if(blue > 255)
		blue = 255;
	_y = (int)((height() - 2) * (1.0f - v));
	foreground(bgcolor);
	fillrect(0, 0, width(), height());
	foreground(map_rgb(red, green, blue));
	fillrect(1, _y + 1, width() - 2, height() - _y - 2);
}
Пример #7
0
void dashboard_window_t::render_progress()
{
	SDL_Rect r;
	int x, y, w, h;

	x = 0;
	w = (int)(_percent * 0.01f * width() + 0.5f);
	if(w < 4)
		w = 4;
	else if(w > width())
		w = width();

	h = 16;
	y = height() - h;

	r.x = x;
	r.y = y;
	r.w = w;
	r.h = h;

	foreground(map_rgb(0x000099));
	rectangle(x, y, w, h);

	++x;
	++y;
	w -= 2;
	h -= 2;
	foreground(map_rgb(0x0000cc));
	rectangle(x, y, w, h);

	++x;
	++y;
	w -= 2;
	h -= 2;
	foreground(map_rgb(0x0000ff));
	fillrect(x, y, w, h);
	
	r.x = 0;
	r.y = height() - 40;
	r.w = width();
	r.h = 12;
	foreground(map_rgb(0x000000));
	fillrect(r.x, r.y, r.w, r.h);
	if(_msg)
	{
		font(B_NORMAL_FONT);
		center(height() - 40, _msg);
	}
}
Пример #8
0
int builtin_fg(int argc, char **argv, int in, int out, int err){

  /* Chop of the command. We don't care about it. */
  ++argv;
  --argc;

  /* Now, we just try and foreground the top of the process group queue. That
   * is to say the last of the processg group queue.
   */
  int state = 0;
  struct rsh_process *proc = NULL;
  struct rsh_process *fg_proc = NULL;
  
  while ( (proc = get_next_proc(&state)) != NULL ){
    if ( ! proc->running )
      fg_proc = proc;
  }

  /* No processes to foreground. */
  if ( ! fg_proc ){
    printf("No process to foreground.\n");
    return 0;
  }

  /* fg_proc is the last process to come out of the process list that is not
   * running. We will run it in the foreground here. */
  return foreground(fg_proc);

}
Пример #9
0
void ImageViewer::watershedClick()
{
    cv::Mat result;
    cv::Mat bgModel, fgModel;
    //cv::Rect rectangle(50, 70, image.cols-150, image.rows-180);
    cv::Rect rectangle2(10,100,380,180);

    cv::grabCut(image,    // input image
                    result,   // segmentation result
                    rectangle2,// rectangle containing foreground
                    bgModel,fgModel, // models
                    5,        // number of iterations
                    cv::GC_INIT_WITH_RECT); // use rectangle

    // Get the pixels marked as likely foreground
    cv::compare(result, cv::GC_PR_FGD, result, cv::CMP_EQ);
    // Generate output image
    cv::Mat foreground(image.size(), CV_8UC3, cv::Scalar(255, 255, 255));
    //image.copyTo(foreground, result); // bg pixels not copied

    // draw rectangle on original image
    //cv::rectangle(image, rectangle, cv::Scalar(255,255,255), 1);

    //foreground.create(image.size(),CV_8UC3);
        //foreground.setTo(cv::Scalar(255,255,255));
        result = result & 1;
        image.copyTo(foreground, result); // bg pixels not copied
        //result = result & 1;

    imageDisplay(foreground);
}
void ChartLabel::paintEvent(QPaintEvent *event)
{
    qDebug() << "paintEvent";
    QPainter painter(this);

    QBrush background = painter.brush();
    QPen foreground(Qt::black);

    painter.setRenderHint(QPainter::Antialiasing);

    painter.fillRect(event->rect(), background);
    painter.setPen(foreground);
    painter.setRenderHint(QPainter::Antialiasing);

    QRect pieRect = QRect(5, 5, 100, 100);

    QMapIterator<QString, int> i(nameValue);
    int startAngle = 0;
    int endAngle = 0;
    while (i.hasNext()) {
        i.next();
        qDebug() << nameColor[i.key()];
        QBrush pieBrush(nameColor[i.key()]);
        painter.setBrush(pieBrush);
        endAngle = 360*nameValue[i.key()]/totalValue;
        qDebug() << endAngle;
        painter.drawPie(pieRect,16*startAngle,16*endAngle);
        startAngle += endAngle;

        //left
        QBrush padBrush(QColor(Qt::cyan));
        painter.setBrush(padBrush);
        painter.drawPie(pieRect,16*startAngle,16*(360-startAngle));
    }
}
Пример #11
0
void QrWidget::draw(QPainter &painter, int width, int height)
{
    QColor foreground(Qt::black);
    painter.setBrush(foreground);
    const int qr_width = qr->width > 0 ? qr->width : 1;

    const double scale_qr_width = qr_width;
    const double scale_width    = width;
    const double scale_height   = height;

    const double double_scale_x = scale_width  / scale_qr_width;
    const double double_scale_y = scale_height / scale_qr_width;

    for (int y = 0; y < qr_width; y ++)
    {
        const double scale_y = y;

        for (int x = 0; x < qr_width; x++)
        {
            const double scale_x = x;

            unsigned char b = qr->data[y * qr_width + x];

            if (b & 0x01)
            {
                QRectF r(scale_x * double_scale_x, scale_y * double_scale_y, double_scale_x, double_scale_y);
                painter.drawRects(&r, 1);
            }
        }
    }
}
Пример #12
0
MSPulldownMenu::MSPulldownMenu(MSMenuBarItem *item_) : MSMenu(item_) 
{
  item()->pulldownMenu(this);
  background(item()->background());
  foreground(item()->foreground());
  font(item()->font());
}
Пример #13
0
MSCascadeMenu::MSCascadeMenu(MSCascadeMenuItem *item_) : MSMenu(item_) 
{
  item()->cascadeMenu(this);
  background(item()->background());
  foreground(item()->foreground());
  font(item()->font());
}
Пример #14
0
void QRWidget::draw(QPainter &painter, int width, int height)
{
    if(NULL != qr)
    {
        QColor background(Qt::white);
        painter.setBrush(background);
        painter.setPen(Qt::NoPen);
        painter.drawRect(0, 0, width, height);

        QColor foreground(Qt::black);
        painter.setBrush(foreground);
        const int qr_width = qr->width > 0 ? qr->width : 1;
        const double scale=(double)((width > height) ? height : width)/qr_width*0.9;
        const int x_first = (width - scale*qr_width)/2;
        const int y_first = (height - scale*qr_width)/2;

        unsigned char *data = qr->data;
        for( int y = 0; y < qr_width; y ++)
        {
            for(int x = 0; x < qr_width; x++)
            {
                unsigned char b = *data++;
                if(b & 0x01)
                {
                    QRectF rect(x * scale + x_first, y * scale + y_first, scale, scale);
                    painter.drawRect(rect);
                }
            }
        }
    }
}
Пример #15
0
void MSWidget::set(MSAttrValueList& avList_)
{
  MSIndexVector index;
  for (unsigned i=0;i<avList_.length();i++)
   {
     if (avList_[i].attribute()=="foreground")
      foreground(avList_[i].value()),index<<i;
     else if (avList_[i].attribute()=="background")
      background(avList_[i].value()),index<<i;
     else if (avList_[i].attribute()=="font")
      font(avList_[i].value()),index<<i;
     else if (avList_[i].attribute()=="acceptFocus")
      acceptFocus(avList_[i].value().asBoolean()),index<<i;
     else if (avList_[i].attribute()=="dynamic")
      dynamic(avList_[i].value().asBoolean()),index<<i;
     else if (avList_[i].attribute()=="sensitive")
      sensitive(avList_[i].value().asBoolean()),index<<i;
     else if (avList_[i].attribute()=="readOnly")
      readOnly(avList_[i].value().asBoolean()),index<<i;
     else if (avList_[i].attribute()=="at")
      at(At(avList_[i].value())),index<<i;
     else if (avList_[i].attribute()=="resizeConstraints")
      resizeConstraints(avList_[i].value()),index<<i;
   } 
  avList_.remove(index);
}
Пример #16
0
bool SeamlessClone::test() {
    // This op is a trivial use of inpaint. If inpaint works so does
    // this. Let's just make sure it doesn't crash.


    // A circular mask
    Image mask(99, 97, 1, 1);
    Expr::X x; Expr::Y y;
    mask.set(Select((x-50)*(x-50) + (y-50)*(y-50) < 30*30, 0, 1));

    // The background is a smooth ramp
    Image background(99, 97, 1, 3);
    background.set((x + 2*y)/300);

    // The foreground to paste on is noise
    Image foreground(99, 97, 1, 3);
    Noise::apply(foreground, 0, 1);

    Image im = background.copy();
    SeamlessClone::apply(im, foreground, mask);

    // The laplacian of the result should be as if you just pasted the
    // laplacian of the foreground on top of the background.
    Image lap(3, 3, 1, 1);
    lap(1, 0) = lap(0, 1) = lap(2, 1) = lap(1, 2) = 1;
    lap(1, 1) = -4;
    Image lapFg = Convolve::apply(foreground, lap, Convolve::Clamp);
    Image lapBg = Convolve::apply(background, lap, Convolve::Clamp);
    Image lapIm = Convolve::apply(im, lap, Convolve::Clamp);
    Composite::apply(lapBg, lapFg, 1-mask);
    return nearlyEqual(lapIm, lapBg);
}
Пример #17
0
			void ButtonTheme::propertyChanged(const event::PropertyEvent &e)
			{
				if(e.getClassID() == event::PropertyEvent::SPECIAL)
				{
					int id = e.getID();

					AbstractButton *comp = static_cast<AbstractButton*>(e.getSource());

					util::Paint *foreground(comp->getForeground());
					util::Paint *background(comp->getBackground());

					switch(id)
					{
					case AbstractButton::SELECTED:
						{
							if(comp->isContentAreaFilled())
							{
								comp->setBackground(foreground);
								comp->setForeground(background);
							}
							break;
						}
					case AbstractButton::DESELECTED:
						{
							if(comp->isContentAreaFilled())
							{
								comp->setBackground(foreground);
								comp->setForeground(background);
							}
							break;
						}
					}
				}
			}
Пример #18
0
void MapGridCtrl::OnGetMapImageAsyncCompleted(const std::string& _mapname)
{
	m_mutex.Lock();
	// if mapname is empty, some error occurred in LSL::usync().GetMinimap...
	if (!m_async_ex.Connected() || !m_async_image.Connected() || _mapname.empty()) {
		m_mutex.Unlock();
		return;
	}
	const wxString mapname = TowxString(_mapname);
	wxImage minimap(LSL::usync().GetScaledMapImage(_mapname, LSL::IMAGE_MAP_THUMB, MINIMAP_SIZE, MINIMAP_SIZE).wximage());

	const int w = minimap.GetWidth();
	const int h = minimap.GetHeight();
	wxImage background(BorderInvariantResizeImage(m_img_background, w, h));
	wxImage minimap_alpha(BorderInvariantResizeImage(m_img_minimap_alpha, w, h));
	wxImage foreground(BorderInvariantResizeImage(m_img_foreground, w, h));

	minimap.SetAlpha(minimap_alpha.GetAlpha(), true /* "static data" */);
	minimap = BlendImage(minimap, background, false);
	minimap = BlendImage(foreground, minimap, false);

	// set the minimap in all MapMaps
	m_maps[mapname].minimap = wxBitmap(minimap);
	m_maps[mapname].state = MapState_GotMinimap;
	if (m_async_ops_count > 0) //WTF, why is this needed?
		m_async_ops_count--;

	// never ever call a gui function here, it will crash! (in 1/100 cases)
	wxCommandEvent evt(REFRESH_EVENT, GetId());
	evt.SetEventObject(this);
	wxPostEvent(this, evt);
	m_mutex.Unlock();
}
Пример #19
0
void MSTableColumnGroup::foreground(const char *foreground_)
{
    if (table()!=0)
    {
        foreground(table()->server()->pixel(foreground_));
    }
}
ServiceMessagesPage::ServiceMessagesPage(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::ServiceMessagesPage),
    clientModel(0),
    walletModel(0)
{
    ui->setupUi(this);

    connect(ui->tableServiceMessagesView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(handleClicked(QModelIndex)));

    QColor foreground(qRgb(48,134,196));
    QStandardItemModel* model = new QStandardItemModel(2, 2, this);

    for (int i = 0; i < 0; ++i)
    {
        QStandardItem* item = new QStandardItem(trUtf8("17:56, 01.03.2012"));
        item->setForeground(foreground);
        model->setItem(i, 0, item);

        item = new QStandardItem(QString::fromUtf8(
                                     i == 0 ?
                                         "":
                                         ""));
        item->setForeground(foreground);
        model->setItem(i, 1, item);
    }

    ui->tableServiceMessagesView->setModel(model);
    ui->tableServiceMessagesView->setColumnWidth(0, 120);
    ui->tableServiceMessagesView->horizontalHeader()->setStretchLastSection(true);
    ui->tableServiceMessagesView->resizeRowsToContents();
}
Пример #21
0
Copyright (C) 1998-2000 Stuart Levy, Tamara Munzner, Mark Phillips";
#endif

#include <stdio.h>
#include "origin.common.h"
#include "forms.h"
#include "xforms-compat.h"
#include "origin.panel.h"

/*
 * This file should contain ONLY the user interface and main()
 * to make splitting off the NeXT version easy
 */

int main(int argc, char *argv[]) {

#ifdef XFORMS
  FL_INITIALIZE("Origin");
#else
  fl_init();
  foreground();
#endif
  
  create_the_forms();
 
  internalsInit();

  fl_show_form(MainForm, FL_PLACE_SIZE, TRUE, "Move Origin");
 
  while(1) fl_do_forms();
}
Пример #22
0
PassRefPtr<SkImageFilter> FEBlend::createImageFilter(SkiaImageFilterBuilder& builder)
{
    RefPtr<SkImageFilter> foreground(builder.build(inputEffect(0), operatingColorSpace()));
    RefPtr<SkImageFilter> background(builder.build(inputEffect(1), operatingColorSpace()));
    sk_sp<SkXfermode> mode(SkXfermode::Make(WebCoreCompositeToSkiaComposite(CompositeSourceOver, m_mode)));
    SkImageFilter::CropRect cropRect = getCropRect();
    return fromSkSp(SkXfermodeImageFilter::Make(std::move(mode), background.get(), foreground.get(), &cropRect));
}
Пример #23
0
void MSOptionPopupMenu::init(void)
{
  _lastShowTime=0;
  _threshold=500;
  foreground(optionMenu()->foreground());
  background(optionMenu()->background());
  font(optionMenu()->font());
}
Пример #24
0
PassRefPtr<SkImageFilter> FEBlend::createImageFilter(SkiaImageFilterBuilder* builder)
{
    RefPtr<SkImageFilter> foreground(builder->build(inputEffect(0), operatingColorSpace()));
    RefPtr<SkImageFilter> background(builder->build(inputEffect(1), operatingColorSpace()));
    RefPtr<SkXfermode> mode(adoptRef(SkXfermode::Create(WebCoreCompositeToSkiaComposite(CompositeSourceOver, m_mode))));
    SkImageFilter::CropRect cropRect = getCropRect(builder->cropOffset());
    return adoptRef(SkXfermodeImageFilter::Create(mode.get(), background.get(), foreground.get(), &cropRect));
}
Пример #25
0
void MSMenuBarItem::updateForeground(unsigned long oldfg_)
{
  MSMenuItem::updateForeground(oldfg_);
  if (pulldownMenu()!=0&&pulldownMenu()->foreground()==oldfg_)
  {
     pulldownMenu()->foreground(foreground());
  }
}
Пример #26
0
void ImageView::paintEvent(QPaintEvent *event)
{
    //QItemSelectionModel *selections = selectionModel();
    QStyleOptionViewItem option = viewOptions();
    //QStyle::State state = option.state;
    //QBrush background = option.palette.base();
    QPen foreground(option.palette.color(QPalette::WindowText));
    //QBrush highlight(option.palette.color(QPalette::Highlight));

    //p.fillRect(event->rect(),background);

    if (!model())
        return;

    QPainter p(viewport());

    int n = model()->rowCount();

    p.translate(-horizontalOffset(),-verticalOffset());

    for (int i=0;i<n;i++)
    {
        QModelIndex index = model()->index(i,0);

        QRect rect = itemRect(index);
        p.setPen(foreground);
        //p.drawRect(rect);

        QVariant decoration = model()->data(index,Qt::DecorationRole);
        if (decoration.type() == QVariant::Pixmap)
        {
            QPixmap pixmap = qvariant_cast<QPixmap>(decoration);
            if (!pixmap.isNull())
            {
                QSize pixmapSize = pixmap.size();
                QSize itemSize = rect.size();
                pixmapSize.scale(itemSize,Qt::KeepAspectRatio);
                QSize rest = (itemSize - pixmapSize)/2;
                QRect pixmapRect(QPoint(rest.width(),rest.height()),pixmapSize);
                pixmapRect.translate(rect.topLeft());
                p.drawPixmap(pixmapRect,pixmap);
            }

        }

        if (index == currentIndex())
        {
            QColor color(option.palette.color(QPalette::Highlight));
            color.setAlpha(100);
            p.fillRect(rect,color);
        }

        //qDebug() << rect << foreground.color() << background.color();
        //p.drawText(rect,Qt::AlignCenter,QString::number(i));
    }

    event->accept();
}
Пример #27
0
PyMODINIT_FUNC
initfl(void)
{
	Py_InitModule("fl", forms_methods);
	if (m == NULL)
		return;
	foreground();
	fl_init();
}
Пример #28
0
/*
 * menu_base_t
 */
void menu_base_t::open()
{
	init(gengine);
	place(wmain->x(), wmain->y(), wmain->width(), wmain->height());
	font(B_NORMAL_FONT);
	foreground(wmain->map_rgb(0xffffff));
	background(wmain->map_rgb(0x000000));
	build_all();
}
void QGraph::paintEvent(QPaintEvent *)
{
    QString yLabel[7] = {"7.0K", "6.5K", "6.0K", "5.5K", "5.0K", "4.5K"};
    QString xLabel[7] = {"-24H", "-20H", "-16H", "-12H", "-8H", "-4H", "NOW"};

    static const QPointF points[6] = {
        QPointF(100, 230),
        QPointF(110.0, 180.0),
        QPointF(120.0, 110.0),
        QPointF(180.0, 130.0),
        QPointF(190.0, 170.0),
        QPointF(700, 230),
    };

    QBrush brush = QBrush(QColor("#333"));
    QPen foreground(QColor("#333"));

    QPainter painter(this);
    painter.setRenderHint(QPainter::Antialiasing);
    painter.setBrush(brush);
    painter.setPen(foreground);
    painter.setFont(QFont(this->font().family(), 9));

    int left, top, w, h, i;
    left = SC_GRAPH_PADDING_LEFT;
    top = SC_GRAPH_PADDING_TOP;
    w = SC_GRAPH_DRAW_WIDTH;
    h = SC_GRAPH_DRAW_HEIGHT;

    // draw graph area
    for (i = 0; i < 5; i++) {
        painter.fillRect(left, top + i * (h / SC_GRAPH_Y_UNIT_COUNT), w, (h / SC_GRAPH_Y_UNIT_COUNT), QColor(i % 2 == 0 ? "#e6e6e6" : "#ffffff"));
    }

    // draw y - axis
    left = SC_GRAPH_PADDING_LEFT;
    top = SC_GRAPH_PADDING_TOP;
    painter.drawLine(left - 10, top, left - 10, top + h);
    painter.drawLine(left, top + h + 10, left + SC_GRAPH_DRAW_WIDTH, top + h + 10);

    for (i = 0; i < 6; i++) {
        left = SC_GRAPH_PADDING_LEFT - 10;
        top = SC_GRAPH_PADDING_TOP + i * SC_GRAPH_Y_UNIT_HEIGHT;
        painter.drawLine(left, top, left - 10, top);
        painter.drawText(QRect(left - 60, top - 10, 40, 20), Qt::AlignCenter, yLabel[i]);
    }

    for (i = 0; i < 7; i++) {
        left = SC_GRAPH_PADDING_LEFT + i * SC_GRAPH_X_UNIT_HEIGHT;
        top = SC_GRAPH_PADDING_TOP + h + 10;
        painter.drawLine(left, top, left, top + 10);
        painter.drawText(QRect(left - 20, top + 20, 40, 20), Qt::AlignCenter, xLabel[i]);
    }

    //draw graph
    painter.drawPolygon(points, 6);
}
void T2FGMM_UV::process(const cv::Mat &img_input, cv::Mat &img_output, cv::Mat &img_bgmodel)
{
  if(img_input.empty())
    return;

  loadConfig();

  if(firstTime)
    saveConfig();

  frame = new IplImage(img_input);
  
  if(firstTime)
    frame_data.ReleaseMemory(false);
  frame_data = frame;

  if(firstTime)
  {
    int width	= img_input.size().width;
    int height = img_input.size().height;

    lowThresholdMask = cvCreateImage(cvSize(width, height), IPL_DEPTH_8U, 1);
    lowThresholdMask.Ptr()->origin = IPL_ORIGIN_BL;

    highThresholdMask = cvCreateImage(cvSize(width, height), IPL_DEPTH_8U, 1);
    highThresholdMask.Ptr()->origin = IPL_ORIGIN_BL;

    params.SetFrameSize(width, height);
    params.LowThreshold() = threshold;
    params.HighThreshold() = 2*params.LowThreshold();
    params.Alpha() = alpha;
    params.MaxModes() = gaussians;
    params.Type() = TYPE_T2FGMM_UV;
    params.KM() = km; // Factor control for the T2FGMM-UM [0,3] default: 1.5
    params.KV() = kv; // Factor control for the T2FGMM-UV [0.3,1] default: 0.6

    bgs.Initalize(params);
    bgs.InitModel(frame_data);
  }

  bgs.Subtract(frameNumber, frame_data, lowThresholdMask, highThresholdMask);
  lowThresholdMask.Clear();
  bgs.Update(frameNumber, frame_data, lowThresholdMask);
  
  cv::Mat foreground(highThresholdMask.Ptr());

  if(showOutput)
    cv::imshow("T2FGMM-UV", foreground);
  
  foreground.copyTo(img_output);

  delete frame;
  firstTime = false;
  frameNumber++;
}