Very nice, Edmondo! Thank you very much for your help and for being so quick to answer! I truly appreciate!
On Monday, May 18, 2020 at 8:05:58 PM UTC+2, Edmondo Giovannozzi wrote: > > You were almost there: > > > import pyqtgraph as pg > import numpy as np > from pyqtgraph.Qt import QtCore, QtGui > > pg.setConfigOptions(imageAxisOrder='row-major') > > app = QtGui.QApplication([]) > > win = pg.GraphicsWindow() > vb = win.addViewBox() > > win.addItem(vb) > v1 = pg.np.random.normal(size=(100, 100)) > > img1 = pg.ImageItem(v1) > v2 = np.zeros(v1.shape+(3,), dtype='uint8') > v2[:,:,0:3] = 128 > v2[40:60, 40:60, 0:3] = 255 > v2[0,:,0]= 255 > v2[:,0,1]= 255 > v2[-1,:,0]= 255 > v2[:,-1,1]= 255 > > img2 = pg.ImageItem(v2) > > vb.addItem(img1) > > vb.addItem(img2) > img2.setZValue(10) > img2.setOpacity(0.5) > #img2.scale(10,10) > win.show() > QtGui.QApplication.instance().exec_() > > > I also added borders of different colours. > > Il giorno lunedì 18 maggio 2020 19:13:07 UTC+2, Jean-Pierre Morichon ha > scritto: >> >> Hi All, >> >> I have a greylevel image and a binary mask. >> I would like to display the binary mask (img2 below) as overlay to the >> greylevel image but with a specific color for the binary mask (let's say >> red) >> >> import pyqtgraph as pg >> import numpy as np >> from pyqtgraph.Qt import QtCore, QtGui >> >> pg.setConfigOptions(imageAxisOrder='row-major') >> >> app = QtGui.QApplication([]) >> >> win = pg.GraphicsWindow() >> vb = win.addViewBox() >> img1 = pg.ImageItem(pg.np.random.normal(size=(100, 100))) >> img2 = np.zeros_like(img1, dtype='uint8') >> img2[40:60, 40:60] = 255 >> vb.addItem(img1) >> vb.addItem(img2) >> img2.setZValue(10) >> img2.setOpacity(0.5) >> img2.scale(10,10) >> win.show() >> >> QtGui.QApplication.instance().exec_() >> >> I have looked for a solution on the net for 3 days wi th no success: the >> only color stuff is about colormaps but I may be wrong but this is not what >> I am lookign for. >> >> Your help would be appreciated >> > -- 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/f2086916-7e50-4d2d-b349-38a1609b799b%40googlegroups.com.
