does  setImage(image, levelMode="rgba", etc.) work for you?

On Wednesday, August 19, 2020 at 3:18:54 PM UTC+2 [email protected] wrote:

> Thank you for your pertinent question!
> I have been stupid assuming that the image was a color image because it 
> was encoded on 4 channels.
> Your simple test made me realize this obvious thing! 
> Fortunately I will not die after such a shame! :-)
>
>
> On Wednesday, August 19, 2020 at 3:12:16 PM UTC+2 [email protected] wrote:
>
>> Howdy,
>>
>> What happens if you add the cv2 item to the view after you fully 
>> initialize it?
>> If you use the imread method with an image file does this work 
>> correctly?  This may help identify if this is an issue with the un-official 
>> openCV release or pyqtgraph
>> something like: 
>>      import cv2 as cv
>>      img = cv.imread(cv.samples.findFile("something.jpg")
>>      cv.imshow("something", img)
>>
>> Cheers,
>> J- 
>>
>> On Wed, Aug 19, 2020 at 8:02 AM [email protected] <[email protected]> 
>> wrote:
>>
>>>
>>> Hi All,
>>>
>>> I have some issues with color using pyqtgraph.
>>> I have a basic code for displaying a RGBA image.
>>> I am expecting to have a color image but instead I have a graylevel image
>>> Do you see an obvious explanation to this behavior in this code ?
>>>
>>> from pyqtgraph.Qt import QtCore, QtGui
>>>
>>> import pyqtgraph as pg
>>>
>>> import cv2
>>>
>>>  
>>>
>>> pg.setConfigOptions(imageAxisOrder='row-major')
>>>
>>>  
>>>
>>> app = QtGui.QApplication([])
>>>
>>> ## Create window with GraphicsView widget
>>>
>>> win = pg.GraphicsLayoutWidget()
>>>
>>> win.show()  ## show widget alone in its own window
>>>
>>> win.setWindowTitle('pyqtgraph example: ImageItem')
>>>
>>> view = win.addViewBox()
>>>
>>> view.invertY(True)
>>>
>>>  
>>>
>>> ## lock the aspect ratio so pixels are always square
>>>
>>> view.setAspectLocked(True)
>>>
>>>  
>>>
>>> ## Create image item
>>>
>>> l_img_item = pg.ImageItem(border='w')
>>>
>>> view.addItem(l_img_item)
>>>
>>> l_img_item.setCompositionMode(QtGui.QPainter.CompositionMode_Plus)
>>>
>>> # l_img_item.setZValue(10)
>>>
>>> # l_img_item.setOpacity(0.5)
>>>
>>>  
>>>
>>> l_image = cv2.imread('_test.png')
>>>
>>> l_image = cv2.cvtColor(l_image, cv2.COLOR_RGBA2RGB)
>>>
>>>  
>>>
>>> ## Set initial view bounds
>>>
>>> view.setRange(QtCore.QRectF(0, 0, 375, 400))
>>>
>>>  
>>>
>>> # timer = QtCore.QTimer()
>>>
>>> # timer.timeout.connect(self._update)
>>>
>>> # timer.start(50)
>>>
>>> l_img_item.setImage(l_image, autoLevels=False)
>>>
>>> l_img_item.setCompositionMode(QtGui.QPainter.CompositionMode_Plus)
>>>
>>> app.exec_()
>>>
>>>
>>> Thanks for your help
>>>
>>>
>>> -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "pyqtgraph" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to [email protected].
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/pyqtgraph/28bcd3c1-bf68-495a-be2d-65e0021f4cd1n%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/pyqtgraph/28bcd3c1-bf68-495a-be2d-65e0021f4cd1n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pyqtgraph/9e0e2398-bc6b-4e84-b62b-17afbe4b0868n%40googlegroups.com.

Reply via email to