Exemplo n.º 1
0
void ImageView::setZoom (bool zoomFit, double factor)
{
    m_zoomFit = zoomFit;
    m_zoomFactor = factor;

    resizeImage();

    update();
}
Exemplo n.º 2
0
void DrawingBoard::resizeEvent(QResizeEvent * event){
  if (width() > image.width() || height() > image.height()){
    int newWidth = qMax(width() + 128, image.width());
    int newHeight = qMax(height() + 128, image.height());
    resizeImage(&image, QSize(newWidth, newHeight));
    update();
  }
  QWidget::resizeEvent(event);
}
Exemplo n.º 3
0
bool DrawArea::saveImage(const QString& fileName, const QString& fileFormat) {
    QImage visibleImage = mImage;
    resizeImage(&visibleImage, this->size());

    if (visibleImage.save(fileName, fileFormat.toLatin1())) {
        mModified = false;
        return true;
    } else
        return false;
}
Exemplo n.º 4
0
	MRI(char const *inputFileName, VolumeType::SpacingType spacing, VolumeType::SizeType size, double initialResizeFactor):
	  resamplerSpacing(spacing),
	  resamplerSize(size) {
		readFile(inputFileName);
		rescaleIntensity();
		resizeImage(initialResizeFactor);
		buildOriginalMaskVolume();
    initialiseFilters();
    buildSlices();
    buildMaskSlices();
	}
Exemplo n.º 5
0
void
RemapImage::setZoom(float z)
{
  setMinimumSize(QSize(m_imgWidth, m_imgHeight));

  m_zoom = qMax(0.01f, z);
  resizeImage();
  update();

  emit zoomChanged();
}
Exemplo n.º 6
0
void Canvas::resizeEvent(QResizeEvent *event)
{
    QSize newSize = event->size();
    if (newSize.height()>image.height()||
            newSize.width()>image.width()) {
        layers.resizeLayers(newSize);
        resizeImage(&image, newSize);
        update();
    }
    QWidget::resizeEvent(event);
}
Exemplo n.º 7
0
void ScribbleArea::resizeEvent(QResizeEvent *event)
{
    if (width() > image.width() || height() > image.height()) {
        int newWidth = qMax(width() , image.width());
        int newHeight = qMax(height() , image.height());
        resizeImage(&image, QSize(newWidth, newHeight));
        update();
    }

    QWidget::resizeEvent(event);
}
Exemplo n.º 8
0
void ComplexPlotter::paintEvent(QPaintEvent *e) {
  if(mRepaintEnabled) {
    qDebug() << "The image computation took " << mStopwatch->elapsed() << " milliseconds";
    mStopwatch->invalidate();
    resizeImage();
    Plotter::paintEvent(e);
    mLabel->setPixmap(QPixmap::fromImage(*mP.mImage));
    setEnabledThreadStuff(true);
    mRepaintEnabled = false;
  }
}
Exemplo n.º 9
0
bool Canvas::openImage(const QString &fileName)
{
    QImage loadedImage;
    if (!loadedImage.load(fileName))return false;
    QSize newSize = loadedImage.size().expandedTo(size());
    resizeImage(&loadedImage, newSize);
    image = loadedImage;
    modified = false;
    update();
    return true;
}
Exemplo n.º 10
0
///
///Private methods
///
void Worker::transformImages(int n,const RoboCompCameraBus::Format& format,RoboCompCameraBus::Image &image)
{
	uint8_t *temp;
	RoboCompCameraBus::Format ftemp;
	ftemp.width = busparams.width;
	ftemp.height = busparams.height;
	ftemp.modeImage = format.modeImage;
	if(format.modeImage != RoboCompCameraBus::YUV422)
	{
		if(format.modeImage == RoboCompCameraBus::GRAY8)
			YUVtoGray(ftemp.width,ftemp.height,pSour,pDes,n);
		else
		{
			if(format.modeImage == RoboCompCameraBus::RGB888Packet)
				YUVtoRGB(ftemp.width,ftemp.height, pSour, pDes,n);
			else
			{
				if(format.modeImage == RoboCompCameraBus::RGB888Planar)
					YUVtoRGBPtr(ftemp.width,ftemp.height,pSour,pDes,n);
			}
		}
		for(int i=0;i<n;i++)
		{
			temp = pSour[i];
			pSour[i] = pDes[i];
			pDes[i] = temp;
		}
	}
	if (ftemp.width != format.width or ftemp.height != format.height)
	{
		resizeImage(ftemp,pSour,format,pDes,n);
		for(int i=0;i<n;i++)
		{
			temp = pSour[i];
			pSour[i] = pDes[i];
			pDes[i] = temp;
		}
	}
	for(int i=0;i<n;i++)	
	{
		if(cameraParamsList[i].invertedH != false or cameraParamsList[i].invertedV != false)
			mirror(format,pSour[i],cameraParamsList[i].invertedH,cameraParamsList[i].invertedV);
	}
	
	int size = format.width*format.height;
	if (format.modeImage == RoboCompCameraBus::RGB888Packet or format.modeImage == RoboCompCameraBus::RGB888Planar)
		size *= 3;
	if (format.modeImage == RoboCompCameraBus::YUV422)
		size *= 2;

	image.timeStamp = reloj.elapsed();
	image.frmt = format;
	image.frmt.size = size;
}
Exemplo n.º 11
0
bool Canvas::saveImage(const QString &fileName, const char *fileFormat)
{
    QImage visibleImage = image;
    resizeImage(&visibleImage, size());
    if (visibleImage.save(fileName, fileFormat)) {
       modified = false;
       return true;
     }
    else{
       return false;
    }
}
Exemplo n.º 12
0
bool DrawingBoard::saveImage(const QString &fileName, const char *fileFormat)
{
    QImage imageOnBoard = image;
    resizeImage(&imageOnBoard, size());

    if (imageOnBoard.save(fileName, fileFormat)) {
        isChanged = false;
        return true;
    } else {
        return false;
    }
}
Exemplo n.º 13
0
bool DrawArea::openImage(const QString &fileName) {
    QImage loadedImage;
    if (!loadedImage.load(QUrl(fileName).toLocalFile()))
        return false;

    QSize newSize = loadedImage.size().expandedTo(this->size());
    resizeImage(&loadedImage, newSize);
    mImage = loadedImage;
    mModified = false;
    update();
    return true;
}
Exemplo n.º 14
0
bool PaintWidget::saveImage(const QString fileName, const char *fileFormat)
{
    QImage visibleImg = image;
    resizeImage(&visibleImg, size());

    if (visibleImg.save(fileName, fileFormat))
    {
        modified = false;
        return true;
    } else
        return false;
}
Exemplo n.º 15
0
bool PaintWidget::openImage(QString fileName)
{
    QImage loadImg;
    if (!loadImg.load(fileName))
        return false;
    QSize newSize = loadImg.size().expandedTo(this->size());
    resizeImage(&loadImg, newSize);
    image = loadImg;
    modified = false;
    update();
    return true;
}
Exemplo n.º 16
0
void PaintCanvas::resizeEvent(QResizeEvent *event)
{
//    if (width() > image.width() || height() > image.height()) {
        //Earlier they wanted a safe margine that the image would draw outside of hence the Qmax
        int newWidth = qMax(width() + 0, image.width());
        int newHeight = qMax(height() + 0, image.height());
        std::cout<<"RESIZEDEVENT  "<<newHeight<<std::endl;

        resizeImage(&image, QSize(newWidth, newHeight));
        update();
//    }
    QWidget::resizeEvent(event);
}
Exemplo n.º 17
0
void ComplexPlotter::doRepaint() {
  setEnabledThreadStuff(false);
  mRepaintEnabled = true;

  resizeImage();
  // call through to the superclass handler
  mStopwatch->start();
  for(int i=mP.mNThreads-1; i>=0; i--)
    // paintThreads[i]->setPlotter(this);
    paintThreads[i]->render(mP, computeCSParameters(mLabel), xMin(), yMin());

  qDebug() << "started " << mP.mNThreads << " threads.";
}
Exemplo n.º 18
0
//! [3]
bool ScribbleArea::saveImage(const QString &fileName, const char *fileFormat)
//! [3] //! [4]
{
    QImage visibleImage = image;
    resizeImage(&visibleImage, size());

    if (visibleImage.save(fileName, fileFormat)) {
        modified = false;
        return true;
    } else {
        return false;
    }
}
Exemplo n.º 19
0
//! [15]
void RotoCanvas::resizeEvent(QResizeEvent *event)
//! [15] //! [16]
{
    if (width() > panelImage.width() || height() > panelImage.height()) {
        int newWidth = qMax(width() + 128, panelImage.width());
        int newHeight = qMax(height() + 128, panelImage.height());
        resizeImage(&panelImage, QSize(newWidth, newHeight));
        QPainter painter(&panelImage);
        painter.drawImage(QPoint(0,0), originalImage);
        update();
    }
    QWidget::resizeEvent(event);
}
Exemplo n.º 20
0
void DrawingBoard::restore()
{
    if(myUndo){

    QSize newSize = bUp.size().expandedTo(size());
    resizeImage(&bUp, newSize);
    bdown=image;
    image=bUp;
myUndo =false;
myRedo =true;
  //  isChanged = false;
    update();
}}
Exemplo n.º 21
0
void DrawingBoard::iRedo()
{
    if(myRedo){
    QSize newSize = bdown.size().expandedTo(size());
    resizeImage(&bdown, newSize);
    bUp=image;
    image=bdown;
myRedo =false;
myUndo = true;
  //  isChanged = false;
    update();
}
}
Exemplo n.º 22
0
bool DrawingBoard::openImage(const QString &fileName)
{
    QImage imageLoaded;
    if (!imageLoaded.load(fileName))
        return false;
   // saving(&image).save();

    QSize newSize = imageLoaded.size().expandedTo(size());
    resizeImage(&imageLoaded, newSize);
    image = imageLoaded;
    isChanged = false;
    update();
    return true;

}
Exemplo n.º 23
0
void PreProcessing::ImageFrameProcessingLogic()
{
	// convert input frame to RGB24 format
	ColorConversion::convertFrameToRGB24();

	// convert RGB frame to byte array
	ColorConversion::convertRGB24ToByteArray();

	// Call some OpenCL Kernel Call
	//cl_tmain();

	// Resize Image using openCV
	resizeImage();

	// get image features
	features = CNTKEvaluator::getFeatures(featureImageHeight, featureImageWidth);
}
Exemplo n.º 24
0
void
RemapImage::setImage(QImage img, int wd, int ht)
{
  m_image = img;

  if (m_image.format() == QImage::Format_Indexed8)
    m_image.setColorTable(m_colorMap);  

  m_imgHeight = ht;    
  m_imgWidth = wd;
//  m_imgHeight = m_image.height();
//  m_imgWidth = m_image.width();

  resizeImage();

  update();
}
Exemplo n.º 25
0
bool ScribbleArea::openImage(const QString &fileName)
{
    QImage loadedImage;
    if (!loadedImage.load(fileName))
        return false;

    QSize newSize = loadedImage.size().expandedTo(size());
    resizeImage(&loadedImage, newSize);
    image = loadedImage;
    modified = false;
    selected = false;
    update();

    imageHistory.clear();
    imageHistory.append(image);
    idxHistory = 0;

    return true;
}
Exemplo n.º 26
0
std::string letterRecognition(cv::Mat image){
	std::string letters[27] = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "*" };
	cv::Mat imgDivide = image.clone();
	imgDivide = removeNoise(image);
	imgDivide = resizeImage(imgDivide);
	int letterInt = compareHistograms(imgDivide);
	//make sure its an M or an N
	if (letterInt == 13 && image.cols >= 55){
		return "M";
	}
	else if (letterInt == 12 && image.cols < 55){
		return "N";
	}
	if (letterInt == 1337)
	{
		return "Error";
	}
	return letters[letterInt];
}
void SerializableRLE8AnimationFrame::read(std::istream& ifs) {
  readStandardBlocks(ifs);
  resizeImage(width_, height_);
//  ifs.read(pixels_, imageDataSize_);

  int imageChunkRemaining = imageDataSize_;

  // read color map
  ifs.read(byteBuffer, ByteSizes::uint32Size);
  int numColors = ByteConversion::fromBytes(byteBuffer,
                                        ByteSizes::uint32Size,
                                        EndiannessTypes::little,
                                        SignednessTypes::nosign);
  imageChunkRemaining -= ByteSizes::uint32Size;
                                        
  for (int i = 0; i < numColors; i++) {
    ifs.read(byteBuffer, ByteSizes::uint32Size);
    int color = ByteConversion::fromBytes(byteBuffer,
                                          ByteSizes::uint32Size,
                                          EndiannessTypes::big,
                                          SignednessTypes::nosign);
    imageChunkRemaining -= ByteSizes::uint32Size;

/*    DrawColor test(color);
    std::cout << std::hex << color << std::endl;
    std::cout << test.a() << std::endl;
    std::cout << test.r() << std::endl;
    std::cout << test.g() << std::endl;
    std::cout << test.b() << std::endl; */
                                        
    externalColorMap.push_back(DrawColor(color));
  }
  
  // read compressed pixel data
  delete loadedCompressedData_;
  loadedCompressedDataSize_ = imageChunkRemaining;
  loadedCompressedData_ = new char[loadedCompressedDataSize_];
  ifs.read(loadedCompressedData_, loadedCompressedDataSize_);
  
  // decompress pixel data
  decompressPixels();
}
Exemplo n.º 28
0
Gui::Gui ( int argc, char** argv, QWidget *parent ) :
    QMainWindow ( parent ),
    ui ( new Ui::Gui )
{
  ui->setupUi ( this );
  cvWindow = new CvWindow ( QString ( "cvWindow" ), CV_WINDOW_AUTOSIZE );

  // set the location of 'cvWindow'
  cvWindow->setParent ( ui->frame );

  readSettings();

  social_robot_gui = new SocialRobotGui ( argc, argv );
  qRegisterMetaType< Mat > ( "Mat" );
  connect ( social_robot_gui, SIGNAL ( update_image ( Mat ) ), this, SLOT ( updateImage ( Mat ) ) );
  social_robot_gui->init();
  // If the frame resizes, update the image size
  connect ( ui->frame, SIGNAL ( resizeImage ( QSize ) ), this, SLOT ( updateImageSize ( QSize ) ) );
  updateImageSize ( ui->frame->size() );
}
Exemplo n.º 29
0
IplImage* crop( IplImage* src,  CvRect roi)
{
    IplImage *imageTmp;
    IplImage * cropped;
    CvSize size;
	size.height = src->height;
	size.width = src->width;
  // Must have dimensions of output image
    imageTmp = cvCreateImage( size, IPL_DEPTH_8U, src->nChannels );
    cvCopy(src, imageTmp, NULL);
  // Say what the source region is
    cvSetImageROI( imageTmp, roi );

    size.width = roi.width;
	size.height = roi.height;
	cropped = cvCreateImage(size, IPL_DEPTH_8U, src->nChannels);
	cvCopy(imageTmp, cropped, NULL);	// Copy just the region.
    cropped = resizeImage(cropped,120,90);
    cvReleaseImage( &imageTmp );
	return cropped;
}
Exemplo n.º 30
0
void ImageDownloadHandle::update()
{
	if(mReq->status() == HttpReq::REQ_IN_PROGRESS)
		return;

	if(mReq->status() != HttpReq::REQ_SUCCESS)
	{
		std::stringstream ss;
		ss << "Network error: " << mReq->getErrorMsg();
		setError(ss.str());
		return;
	}

	// download is done, save it to disk
	std::ofstream stream(mSavePath, std::ios_base::out | std::ios_base::binary);
	if(stream.bad())
	{
		setError("Failed to open image path to write. Permission error? Disk full?");
		return;
	}

	const std::string& content = mReq->getContent();
	stream.write(content.data(), content.length());
	stream.close();
	if(stream.bad())
	{
		setError("Failed to save image. Disk full?");
		return;
	}

	// resize it
	if(!resizeImage(mSavePath, mMaxWidth, mMaxHeight))
	{
		setError("Error saving resized image. Out of memory? Disk full?");
		return;
	}

	setStatus(ASYNC_DONE);
}