//---------------------------------------- // callback function for redraw events //---------------------------------------- // void QFunctionEditor:: paintEvent( QPaintEvent *e) { QWidget::paintEvent( e ); QRect region = e->rect(); QPainter painter(this); painter.fillRect(region, m_brushBG); drawFrame(&painter); drawTicks(&painter); if(m_nInternalMode == INTERNAL_MODE_COLOR_TABLE) { drawHistogram(&painter, 0, 255); drawColorTable(&painter,region.x()-2, region.x() + region.width()+5); } else { drawHistogram(&painter, 0, 255); drawColorMap(&painter,region.x()-2, region.x() + region.width()+5); } drawLimits(&painter); }
void Background::computeBasicModel() { // std::cout << "Computing basic background model.." << std::endl; assert(video.isOpened()); cv::Mat frame, gray; // read frame by frame and process while(video.read(frame)) { // convert to grayscale and apply Gaussian blur cv::cvtColor(frame, gray, CV_RGB2GRAY); grayscaleGaussianBlur(gray, gray, 5); for (int row = 0; row < gray.rows; ++row) { #pragma omp parallel for for (int col = 0; col < gray.cols; ++col) { pixels[row * width + col].push_back((int)gray.at<uchar>(row, col)); } } frames.push_back(gray.clone()); } // compute medians and get background model for (int row = 0; row < backgroundModel.rows; ++row) { #pragma omp parallel for for (int col = 0; col < backgroundModel.cols; ++col) { backgroundModel.at<uchar>(row, col) = getMean(pixels[row * width + col]); } } cv::Mat hist; cv::Mat centralBgModel = cv::Mat(backgroundModel, cv::Range(0, backgroundModel.rows*(1.0 - MARGIN_BOTTOM)), cv::Range(backgroundModel.cols * MARGIN_SIDE, backgroundModel.cols*(1.0 - MARGIN_SIDE))); bgModelHist = computeHistogram(centralBgModel); drawHistogram(bgModelHist, hist); // cv::namedWindow( "Background", CV_WINDOW_AUTOSIZE ); // cv::imshow( "Background", backgroundModel ); // cv::namedWindow( "Histogram", CV_WINDOW_AUTOSIZE ); // cv::imshow( "Histogram", hist ); adjustBackgroundModel(); drawHistogram(bgModelHist, hist); // cv::namedWindow( "Adjusted background", CV_WINDOW_AUTOSIZE ); // cv::imshow( "Adjusted background", backgroundModel ); // cv::namedWindow( "Adjusted histogram", CV_WINDOW_AUTOSIZE ); // cv::imshow( "Adjusted histogram", hist ); // cv::waitKey(0); // exit(0); }
/// /// reimplemented functions /// void MemChartPrivate::paintEvent(QPaintEvent *e) { QPainter painter(this); drawBackground(&painter); drawCaption(&painter); drawFrame(&painter); drawLegend(&painter); drawHistogram(&painter); drawSelectedRegion(&painter); }
void TImageSnapshot::showParams() { QImage tempImg = wgt->image; if (manipulatorIsClosed) { manip = new ImageManipulator(QList<QVariant>() << imageParams.brightness << imageParams.contrast << wgt->imageTransform.rotate + serverValues[0] << imageParams.gamma << picMode->getLBorder() << picMode->getRBorder() << wgt->imageTransform.horFlip << wgt->imageTransform.verFlip << wgt->imageTransform.imageScale << picMode->_maxContrast << _timer << picMode->getPictureMode() << wgt->imageTransform.fullPictureMode << wgt->moveX << wgt->moveY << dimX / picMode->getDelimitr() << dimY, val16, tempImg); manip->setAttribute(Qt::WA_DeleteOnClose); manipulatorIsClosed = false; manip->setModal(true); connect(manip, SIGNAL(destroyed()), this, SLOT(manipDestroed())); connect(manip, SIGNAL(setBr(QVariant)), this, SLOT(setBrightness(QVariant))); connect(manip, SIGNAL(setCon(QVariant)), this, SLOT(setContrast(QVariant))); connect(manip, SIGNAL(setGm(QVariant)), this, SLOT(setGamma(QVariant))); connect(manip, SIGNAL(setLBorder(unsigned short)), this, SLOT(setLBorder(unsigned short))); connect(manip, SIGNAL(setRBorder(unsigned short)), this, SLOT(setRBorder(unsigned short))); connect(manip, SIGNAL(sendRotationVal(QVariant)), this, SLOT(setRotate(QVariant))); connect(manip, SIGNAL(sendHorFlipVal(QVariant)), this, SLOT(setHFlip(QVariant))); connect(manip, SIGNAL(sendVerFlipVal(QVariant)), this, SLOT(setVFlip(QVariant))); //connect(manip, SIGNAL(changeFormatOfColor(int)), this, SLOT(setImageType(int))); connect(manip, SIGNAL(changePictureModeSignal(int)), this, SLOT(setImageType(int))); connect(manip, SIGNAL(setTime(int)), this, SLOT(sendTimer(int))); connect(manip, SIGNAL(setScaleSignal(double)), this, SLOT(setScale(double))); connect(manip, SIGNAL(fullScreenMode(bool)), this, SLOT(setFullscreenMode(bool))); connect(manip, SIGNAL(getDataHistogram()), this, SLOT(drawHistogram())); connect(manip, SIGNAL(chPicX(int)), wgt, SLOT(setMoveX(int))); connect(manip, SIGNAL(chPicY(int)), wgt, SLOT(setMoveY(int))); connect(wgt, SIGNAL(showPictureSize(int, int, int, int)), manip, SLOT(setShowPicSize(int, int, int, int))); setImage(wgt->image); manip->show(); } }
void draw(){ ofPushMatrix(); ofSetColor(0); drawAngle(); ofTranslate(140, 0); drawGraph(); drawInfo(); ofTranslate(N + 20, 0); drawHistogram(); ofPopMatrix(); }
void draw() { ofPushMatrix(); float screenWidth = config["screen"]["width"]; float screenHeight = config["screen"]["height"]; float camWidth = config["camera"]["width"]; float camHeight = config["camera"]["height"]; ofTranslate(screenWidth / 2, screenHeight / 2); ofRotateZDeg(config["camera"]["rotate"]); ofTranslate(-camWidth / 2, -camHeight / 2); if(cam->isInitialized()) { cam->draw(0,0); } clipping.draw(0, 0); ofPopMatrix(); if(cam->isInitialized()) { drawHistogram(cam->getPixels(), mouseY); } }
/* drawGrid() Draws the map, and people. */ void drawGrid () { PERSON *thePerson = personHeader; int y; int x; int i; for (y = 0; y < mapWidth; y++) { for (x = 0; x < mapWidth; x++) { //Draw the squares draw_sprite(screenBuffer, aMapSquare[x][y].picture, placeOnGridX(x, y), placeOnGridY(x, y) - anObject[aMapSquare[x][y].objectType].printOffset); drawHistogram(x,y); /* Drawing people Because people are always moving, ther can be no fixed order for printing them. Instead, they are constantly sorted, and once sorted, this loop prints them. They are sorted by gridX and gridY, in the same order as the squares. Thus, while stepping though the squares, you can step through the list of people and print all of them until you reach the next square */ while (thePerson != NULL && thePerson->gridY == y && thePerson->gridX == x) { drawPerson(thePerson); thePerson = thePerson->next; } } } if(showPersonInfo) { for(i = 0; i < NUMRESOURCES; i++) { if (selectionX != -1 && selectionY != -1){ if (aMapSquare[selectionX][selectionY].walker[i] != NULL) { thePerson = aMapSquare[selectionX][selectionY].walker[i]; line(screenBuffer, thePerson->x + cameraX, thePerson->y + cameraY - 15, placeOnGridX(selectionX, selectionY) + squareWidth/2, placeOnGridY(selectionX, selectionY) + squareWidth/4, resourceColour[i]); } } } } }
//----------- void ModuleImageAnalyzer::drawHistograms() { ofSetColor(255, 0, 0); r.draw(0, 0); drawHistogram(histogramR); ofTranslate(width, 0); ofSetColor(0, 255, 0); g.draw(0, 0); drawHistogram(histogramG); ofTranslate(width, 0); ofSetColor(0, 0, 255); b.draw(0, 0); drawHistogram(histogramB); ofTranslate(-2*width, height); ofSetColor(255); h.draw(0, 0); drawHistogram(histogramH); ofTranslate(width, 0); ofSetColor(255); s.draw(0, 0); drawHistogram(histogramS); ofTranslate(width, 0); ofSetColor(255); v.draw(0, 0); drawHistogram(histogramV); ofTranslate(-2*width, -height); image.draw(10, 10, 500, 400); ofDrawBitmapString("red", 0, 15); ofDrawBitmapString("green", width, 15); ofDrawBitmapString("blue", 2*width, 15); ofDrawBitmapString("hue", 0, 15+height); ofDrawBitmapString("saturation", width, 15+height); ofDrawBitmapString("value", 2*width, 15+height); }
void P4Monochrome::createHistogram() { int* colors = readPixelsIntoArray("P4"); drawHistogram(colors, "P4"); }
void QgsHistogramWidget::refresh() { drawHistogram(); }
bool TrackerThread::work() { if ((m_HistoryDelay + m_StartTime) < TimeSource::get()->getCurrentMillisecs() && m_HistoryDelay != -1) { resetHistory(); m_HistoryDelay = -1; } BitmapPtr pCamBmp; { ScopeTimer timer(ProfilingZoneCapture); pCamBmp = m_pCamera->getImage(true); BitmapPtr pTempBmp1; while ((pTempBmp1 = m_pCamera->getImage(false))) { m_NumCamFramesDiscarded++; m_NumFrames++; pCamBmp = pTempBmp1; } } long long time = TimeSource::get()->getCurrentMillisecs(); if (pCamBmp) { m_NumFrames++; ScopeTimer timer(ProfilingZoneTracker); if (m_pCameraMaskBmp) { ScopeTimer timer(ProfilingZoneMask); FilterMask(m_pCameraMaskBmp).applyInPlace(pCamBmp); } if (m_bCreateDebugImages) { boost::mutex::scoped_lock lock(*m_pMutex); *(m_pBitmaps[TRACKER_IMG_CAMERA]) = *pCamBmp; ScopeTimer timer(ProfilingZoneHistogram); drawHistogram(m_pBitmaps[TRACKER_IMG_HISTOGRAM], pCamBmp); } { if (m_Prescale != 1) { ScopeTimer timer(ProfilingZoneDownscale); FilterFastDownscale(m_Prescale).applyInPlace(pCamBmp); } } BitmapPtr pDistortedBmp; { ScopeTimer timer(ProfilingZoneDistort); pDistortedBmp = m_pDistorter->apply(pCamBmp); } BitmapPtr pCroppedBmp(new Bitmap(*pDistortedBmp, m_ROI)); if (m_bCreateDebugImages) { boost::mutex::scoped_lock lock(*m_pMutex); m_pBitmaps[TRACKER_IMG_DISTORTED]->copyPixels(*pCroppedBmp); } if (m_pHistoryPreProcessor) { ScopeTimer timer(ProfilingZoneHistory); m_pHistoryPreProcessor->applyInPlace(pCroppedBmp); } if (m_bCreateDebugImages) { boost::mutex::scoped_lock lock(*m_pMutex); m_pBitmaps[TRACKER_IMG_NOHISTORY]->copyPixels(*pCroppedBmp); FilterNormalize(2).applyInPlace(m_pBitmaps[TRACKER_IMG_NOHISTORY]); } { BitmapPtr pBmpBandpass; if (m_TouchThreshold != 0) { { ScopeTimer timer(ProfilingZoneBandpass); pBmpBandpass = m_pBandpassFilter->apply(pCroppedBmp); } if (m_bCreateDebugImages) { boost::mutex::scoped_lock lock(*m_pMutex); *(m_pBitmaps[TRACKER_IMG_HIGHPASS]) = *pBmpBandpass; } } calcBlobs(pCroppedBmp, pBmpBandpass, time); } ThreadProfiler::get()->reset(); } return true; }
void QgsHistogramWidget::refreshAndRedraw() { refreshHistogram(); drawHistogram(); }
void P3Grayscale::createHistogram() { int* colors = readPixelsIntoArray("P3"); drawHistogram(colors, "P3"); }
int main(int argc, char* argv[]) { IplImage* src = cvLoadImage(argv[1],CV_LOAD_IMAGE_UNCHANGED); // get HSV form of image IplImage* hsvSrc = cvCreateImage(cvGetSize(src),8,3); cvCvtColor(src,hsvSrc,CV_BGR2HSV); // initialize Histogram int numBins = 256; CvHistogram *hist = cvCreateHist(1,&numBins,CV_HIST_ARRAY,NULL,1); cvClearHist(hist); // Separate hsv image into 3 channels IplImage* hueCh = cvCreateImage(cvGetSize(hsvSrc),8,1); IplImage* satCh = cvCreateImage(cvGetSize(hsvSrc),8,1); IplImage* valCh = cvCreateImage(cvGetSize(hsvSrc),8,1); cvSplit(hsvSrc,hueCh,satCh,valCh,NULL); // **** Rendering Histogram **** // --- Hue Channel --- cvCalcHist(&hueCh,hist, 0, NULL); IplImage* imgHistHue = drawHistogram(hist); cvClearHist(hist); // --- Sat Channel --- cvCalcHist(&satCh, hist, 0, NULL); IplImage* imgHistSat = drawHistogram(hist); cvClearHist(hist); // --- Val Channel --- cvCalcHist(&valCh, hist, 0, NULL); IplImage* imgHistVal = drawHistogram(hist); cvClearHist(hist); cvStartWindowThread(); // display histogram cvNamedWindow("Hue",CV_WINDOW_NORMAL); cvNamedWindow("Sat",CV_WINDOW_NORMAL); cvNamedWindow("Val",CV_WINDOW_NORMAL); cvShowImage("Hue",imgHistHue); cvShowImage("Sat",imgHistSat); cvShowImage("Val",imgHistVal); // wait for key press cvWaitKey(0); // release memory cvDestroyAllWindows(); cvReleaseImage(&src); cvReleaseImage(&hueCh); cvReleaseImage(&satCh); cvReleaseImage(&valCh); cvReleaseImage(&imgHistHue); cvReleaseImage(&imgHistSat); cvReleaseImage(&imgHistVal); return 0; }// end of main
void MSAEditorConsensusArea::paintFullConsensus(QPainter &p) { p.fillRect(QRect(0, 0, ui->seqArea->getXByColumnNum(ui->editor->getAlignmentLen()), getYRange(MSAEditorConsElement_RULER).startPos), Qt::white); drawConsensus(p, 0, ui->editor->getAlignmentLen() - 1, true); drawHistogram(p, 0, ui->editor->getAlignmentLen() - 1); }