Exemple #1
0
void ImageView::canny()
{
  IplImage *currentIpl = ImageToIplImage(&currentPixmap);
  if(currentIpl == 0)
    return;
  //!

  IplImage *dst = toGray(currentIpl);

  float r = random();
  int low = static_cast<int>(r*150+0.5);
  int high = static_cast<int>(r*200+0.5);
  cvCanny(dst, dst, low, high);       // ALGORITHMS

  QImage *image = 0;
  if(dst->width > MAX_ALLOWED_SIZE)
    {
      image = IplImage2QImageLowEffect(dst);
    } else
    {
      image = IplImageToQImage(dst, (uchar**)&dst->imageData, 0, 0);
    }
  currentPixmap = QPixmap::fromImage(*image);     /// @warning BIG IMAGE CORRUCTED
  update();   // Update the curreent image

  cvReleaseImage(&dst);
  cvReleaseImage(&currentIpl);
  delete image;
  ui->statusBar->showMessage("Canny");
}
Exemple #2
0
int main(int argc, char** argv)
{
	if(argc != 2)
	{
		printf("Usage:test xxx.jpg\n");
		return 1;
	}

	IplImage* img = cvLoadImage(argv[1],
			CV_LOAD_IMAGE_ANYDEPTH|CV_LOAD_IMAGE_ANYCOLOR);//如果想要载入最真实的图像,选择CV_LOAD_IMAGE_ANYDEPTH | CV_LOAD_IMAGE_ANYCOLOR。
	if(NULL == img)
	{
		printf("Image load fail!\n");
		return 2;
	}

	cvNamedWindow("RGB", CV_WINDOW_AUTOSIZE);
	cvShowImage("RGB", img);

	toGray(img);

	cvReleaseImage(&img);
	cvDestroyWindow("RGB");

}
Exemple #3
0
void ImageView::gLCM()
{
  //! If you want use OpenCV to process the current opening "QpixMap" format image.
  //!
  IplImage *currentIpl = ImageToIplImage(&currentPixmap);
  if(currentIpl == 0)
    return;
  //!

  IplImage *grayImg = toGray(currentIpl);
  if(grayImg ==NULL)
    return;

#if(0)  //! Test color-gray dconvert
  cvNamedWindow("Test Gray", CV_WINDOW_AUTOSIZE);
  cvShowImage("Test Gray", grayImg);
  cvWaitKey(0);
#endif

  //! Deal the new image with GLCM method and show the diagram
  glcm->runGLCMAndGetParams(grayImg);
  if(glcm->isHidden())
    glcm->show();
  //!

  ui->statusBar->showMessage("GLCM Procesing");

  //! Release Memory
  cvReleaseImage(&currentIpl);
  cvReleaseImage(&grayImg);
}
Exemple #4
0
void ImageView::bilateral_smooth()
{
  IplImage *currentIpl = ImageToIplImage(&currentPixmap);
  if(currentIpl == 0)
    return;

  IplImage *grayImage = toGray(currentIpl);
  IplImage *dst = cvCloneImage(grayImage);
  cvSmooth(grayImage, dst, CV_BILATERAL, 3, 0, 0, 0);
  cvReleaseImage(&grayImage);

  QImage *image = 0;
  if(dst->width > MAX_ALLOWED_SIZE)
    {
      image = IplImage2QImageLowEffect(dst);
    } else
    {
      image = IplImageToQImage(dst, (uchar**)&dst->imageData, 0, 0);
    }
  currentPixmap = QPixmap::fromImage(*image);
  update();   // Update the curreent image

  delete image;
  cvReleaseImage(&dst);
  cvReleaseImage(&currentIpl);
  ui->statusBar->showMessage("Bilateral Smooth");
}
Exemple #5
0
QImage KIconEffect::apply(const QImage &img, int effect, float value,
                          const QColor &col, const QColor &col2, bool trans) const
{
    QImage image = img;
    if (effect >= LastEffect) {
        qWarning() << "Illegal icon effect: " << effect;
        return image;
    }
    if (value > 1.0) {
        value = 1.0;
    } else if (value < 0.0) {
        value = 0.0;
    }
    switch (effect) {
    case ToGray:
        toGray(image, value);
        break;
    case DeSaturate:
        deSaturate(image, value);
        break;
    case Colorize:
        colorize(image, col, value);
        break;
    case ToGamma:
        toGamma(image, value);
        break;
    case ToMonochrome:
        toMonochrome(image, col, col2, value);
        break;
    }
    if (trans == true) {
        semiTransparent(image);
    }
    return image;
}
void ClassifiedViewer::setTestImage(QString imageFile)
{
  m_image = QImage(imageFile);

  // convert image to grayscale
  m_grayscaleImage = QImage(m_image.width(), m_image.height(), m_image.format());
  for (int h=0; h<m_image.height(); h++){
    for (int w=0; w<m_image.width(); w++){
      m_grayscaleImage.setPixel(w, h, toGray(m_image.pixel(w, h)));
    }
  }
  scaleImage();

  drawScene();
}
Exemple #7
0
void ImageView::median_smoooth()
{
  IplImage *currentIpl = ImageToIplImage(&currentPixmap);
  if(currentIpl == 0)
    return;

  IplImage *grayImage = toGray(currentIpl);
  IplImage *dst = cvCloneImage(grayImage);
  cvSmooth(grayImage, dst, CV_MEDIAN, 3, 0, 0, 0);
  cvReleaseImage(&grayImage);

  QImage *image = 0;
  if(dst->width > MAX_ALLOWED_SIZE)
    {
      image = IplImage2QImageLowEffect(dst);
    } else
    {
      image = IplImageToQImage(dst, (uchar**)&dst->imageData, 0, 0);
    }
  currentPixmap = QPixmap::fromImage(*image);
  update();   // Update the curreent image

  delete image;
  cvReleaseImage(&dst);
  cvReleaseImage(&currentIpl);
  ui->statusBar->showMessage("Median Smooth");

#if(0) // Testing Code
  IplImage *ipl = cvLoadImage("E:/yang.jpg");
  cvNamedWindow("AAA",CV_WINDOW_AUTOSIZE);
  cvShowImage("AAA", ipl);

  QImage *image = IplImageToQImage(ipl, (uchar**)&ipl->imageData, 0, 0);
  currentPixmap = QPixmap::fromImage(*image);
  update();
  cvWaitKey(0);
  cvReleaseImage(&ipl);
  cvDestroyWindow("AAA");
  delete image;
#endif
}
//被handle_friend_ack调用
int qmainstackwidget::_add_friend(string id, string name, string image__, string image_name, string isonline,  int key)
{
	QPixmap pix;
	if (strcmp(image__.data(), "0"))
	{
		QDir *temp = new QDir;
		bool exist = temp->exists("friend_head");
		if (!exist)
			bool ok = temp->mkdir("friend_head");
		QString idd = QString::fromStdString(id);
		string file_name__ = "friend_head/";
		file_name__ += image_name;
		QString gray_name = "friend_head/gray_" + QString::fromStdString(image_name);
		ofstream fd(file_name__, std::ios::out | std::ios::binary);
		fd.write(image__.data(), image__.size());
		fd.close();
		QImage image(QString::fromStdString(file_name__));
		QImage im = toGray(image);
		pix.load(QString::fromStdString(file_name__));	
		im.save(gray_name);
	}
	else
	{
		pix.load(QString::fromStdString("friend_head/qq"));
		
	}
	if (key == 4){
		box_people->add_widget(pix, name.data(), id, 0, isonline);
		
	}
	else
	{
		box_people->add_widget(pix, name.data(), id, key, isonline);
	}
	
	return 1;
}
// 这是主 DLL 文件。

#include "stdafx.h"

#include "FaceDetectManaged.h"

List<Rectangle>^ FaceDetectManaged::FaceDetectManaged::FrontalDetect(Bitmap^ bmp, float scale, int min_nb, int min_size, int max_size)
{
	int stride;
	unsigned char* buf = toGray(bmp, stride);
	List<Rectangle> ^r = toList(facedetect_frontal(buf, bmp->Width, bmp->Height, stride, scale, min_nb, min_size, max_size));
	delete[] buf;
	return r;
}

List<Rectangle>^ FaceDetectManaged::FaceDetectManaged::MultiviewDetect(Bitmap^ bmp, bool frontalPrior, float scale, int min_nb, int min_size, int max_size)
{
	int stride;
	unsigned char* buf = toGray(bmp, stride);
	List<Rectangle> ^r;
	if (frontalPrior)
		r = toList(facedetect_frontal(buf, bmp->Width, bmp->Height, stride, scale, min_nb, min_size, max_size));
	if (r && r->Count == 0)
		List<Rectangle> ^r = toList(facedetect_multiview(buf, bmp->Width, bmp->Height, stride, scale, min_nb, min_size, max_size));
	delete[] buf;
	return r;
}

List<Rectangle>^ FaceDetectManaged::FaceDetectManaged::toList(int* arr)
{
	List<Rectangle>^ res = gcnew List<Rectangle>();