qimage

Set pixel value of 16 bit grayscale QImage

蹲街弑〆低调 提交于 2019-12-23 04:56:43
问题 I have an 16 bit image of width ("imagewidth") and height ("imageheight"). The data is currently stored in an unsigned short int array of length ("imagewidth"*"imageheight") I want to create an 16 bit grayscale QImage (using Qt 5.14) from my dataset which is called "data". This is the code that I am using: QImage image = Qimage(imagewidth,imageheight,QImage::Format_Grayscale16); for(int i=0;i<imagewidth;i++) { for(int j=0;j<imageheight;j++) { uint pixelval = data[i+j*imagewidth]; QRgb color =

Why is there bit shifting when converting to an image from an array?

ぃ、小莉子 提交于 2019-12-22 11:27:47
问题 I'm trying to create a QPixmap from a numpy array. The numpy array image is going to be 2D (ie no color info just grayscale). I'm trying to adapt this answer to my needs however I don't quite understand this line: b = (255 << 24 | a[:,:,0] << 16 | a[:,:,1] << 8 | a[:,:,2]).flatten() # pack RGB values There is some bitshifting going on and some bitwise or ' ing but I don't quite get it to be honest. So my dumbed down example is as follows: x, y = np.meshgrid(np.arange(1920), np.arange(1080),

QImage in a QGraphics scene

柔情痞子 提交于 2019-12-20 10:35:19
问题 I am quite new to Qt. I am having troubles in inserting a QImage to a scene. Could somebody please tell me how to add a QImage to a QGraphicsScene ? 回答1: For this you would use a QGraphicsPixmapItem that you add to the scene like any other QGraphicsItem . The QGraphicsPixmapItem can be initialized with a QPixmap which is a device-dependent representation of a bitmap and you can get it from a QImage for example with the static function QPixmap::fromImage(). Update (example code) #include

Fastest method to convert IplImage IPL_DEPTH_32S to QImage Format_RGB32

六眼飞鱼酱① 提交于 2019-12-20 06:49:14
问题 What is the fastest method to convert IplImage IPL_DEPTH_32S to QImage Format_RGB32? I need to catch pictures from cam and show it on form with frequency 30 frames in second. I tried to use QImage constructor: QImage qImage((uchar *) image->imageData, image->width, image->height, QImage::Format_RGB32); but image was corrupted after this. So, how can I do this fast (I think putting pixel by pixel into QImage is not a good decision)? 回答1: Before I start, OpenCV uses the BGR format by default .

Image copied to clipboard doesn't persist on Linux

懵懂的女人 提交于 2019-12-20 04:48:14
问题 I'm trying to save an image to the system clipboard, so I wrote some code like this: #!/usr/bin/python3 from PyQt5.Qt import QApplication from PyQt5.QtWidgets import QWidget, QPushButton from PyQt5.Qt import QImage import sys class MyWidget(QWidget): def __init__(self): super(MyWidget, self).__init__() self.button = QPushButton(self) self.button.clicked.connect(self.copyPicToClip) def copyPicToClip(self): image = QImage('./test.jpg') QApplication.clipboard().setImage(image) self.close() if _

Is QImage able to open and render pure 16-bit images?

一曲冷凌霜 提交于 2019-12-20 04:26:11
问题 I think the headline already explains what I want to know. Is there a possible way to open and save images with 16-bit with Qt? And I don't mean the 3*8=24bit or 4*8=32bit, what is quite the same as a pure 8-bit image, I mean pure 16-bit for R, G and B. 回答1: Contrary to what Patrice says, there is no 16 bits per component format in QImage . The most you can get is QImage::Format_ARGB32 at 8 bits per component. Even if you used 8 bits indexed mode, the color tables do not support more than 8

Qt does not load JPG , just PNG

人盡茶涼 提交于 2019-12-19 21:27:08
问题 I work with my colleagues on the same project on Windows 7 64 bit version, Visual Studio 2008. They load JPG and they work. Through QPixmap and Stylesheets. And works. But for me, i can only work with PNG, the rest don´t work at all. I also tried to change paths on the environment variables, but i only see one Qt path (the bin) on it. Nothing about plugins, i guess... as i read on the documentation: "By default, Qt can read the following formats: Format Description BMP Windows Bitmap GIF

Convert 16-bit grayscale to QImage

£可爱£侵袭症+ 提交于 2019-12-18 06:50:23
问题 I am working on a sensor-based Python application built on a PyQt4 GUI. The sensor is generating 16-bit measurements... 256 16-bit "pixels" per "line". A square "image" is acquired by obtaining 256 lines, resulting in a (256,256) Numpy array of 16-bit numbers. I simply want to display this as a grayscale image. The sensor loop is running in a QThread and emits a QImage signal. The signal connects to a slot that renders the data in the main GUI by packing it into a 32-bit RGB image. Of course,

Convert Python Opencv Image (numpy array) to PyQt QPixmap image

空扰寡人 提交于 2019-12-17 22:25:26
问题 I am trying to convert python opencv image to QPixmap. I follow the instruction shows Page Link and my code is attached below img = cv2.imread('test.png')[:,:,::1]/255. imgDown = cv2.pyrDown(img) imgDown = np.float32(imgDown) cvRGBImg = cv2.cvtColor(imgDown, cv2.cv.CV_BGR2RGB) qimg = QtGui.QImage(cvRGBImg.data,cvRGBImg.shape[1], cvRGBImg.shape[0], QtGui.QImage.Format_RGB888) pixmap01 = QtGui.QPixmap.fromImage(qimg) self.image01TopTxt = QtGui.QLabel('window',self) self.imageLable01 = QtGui

Display QImage with QtGui

二次信任 提交于 2019-12-17 10:23:41
问题 I am new to Qt, and I am trying to create a simple GUI Application that displays an image once a button has been clicked on. I can read the image in a QImage object, but is there any simple way to call a Qt function that takes the QImage as an input, and displays it? 回答1: Simple, but complete example showing how to display QImage might look like this: #include <QtGui/QApplication> #include <QLabel> int main(int argc, char *argv[]) { QApplication a(argc, argv); QImage myImage; myImage.load(