Hi,

I'm not totally sure I understand the question, but if you want to just 
mask off regions in the image you could simply merge the mask information 
to the alpha channel of the image. ImageItem pixel data (for a single image 
frame) can be four dimensional (R, G, B, A), where A is the 
alpha/transparency. Set the A channel according to your mask (0 = 
transparent, 255 = opaque). For the time series data you'll just push that 
dimension along one. You'll need to play with the various numpy 
slicing/concatenation methods to merge the data correctly.

As a very simple example, if you look at the ImageView example, you can 
insert/change the following and the images will have that alpha/mask info. 
This is a poor example since every pixel has the same alpha=128, but it 
should give you the idea:

dataAlpha = 128*np.ones_like(dataRed)
data = np.concatenate(
    (dataRed[:, :, :, np.newaxis], dataGrn[:, :, :, np.newaxis], dataBlu[:, 
:, :, np.newaxis], dataAlpha[:, :, :, np.newaxis]), axis=3
)

Patrick


On Thursday, 23 June 2022 at 9:44:25 pm UTC+9:30 [email protected] 
wrote:

> Hello everyone! 
>
> I am relatively new to pyqtgraph and recently I have been using it for a 
> GUI that visualizes medical image data. What you can do is drag and drop 
> files into an ImageView, visualize for example a CT image and scroll 
> through the CT-volume (since pyqt graph nicely detects the 3d array and 
> adds the third axis as "time" axis which in this case allows to scroll 
> through the volume). 
> I also have image masks of the same dimension as the original image (also 
> 3d numpy arrays) and I want to overlay image and mask and ideally adapt the 
> transparency of both. Currently I am doing this by calculating a completely 
> new array which combines both image mask and image (I normalize both and 
> then create a weighted sum of both arrays). This works but has some 
> disadvantages, for example I cannot color mask and image separately. 
> My Question is now: do you know another way how I can overlay both 
> 3D-arrays (mask + image) as separate layers while keeping the possibility 
> to scroll through the volume, such that both mask and image change when 
> scrolling through the volume (see images)? I tried around with the addItem 
> method defined in the ViewBox class, but without any success. 
> I would really appreciate some help and ideas. 
>
> Kind regards and thanks in advance
> Alex
>
> Image at certain z-value of volume:
> [image: Screenshot 2022-06-23 135542.jpg]
>
> Image after scrolling through volume at different z-value:[image: 
> Screenshot 2022-06-23 135607.jpg]
>

-- 
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/2d6ffb96-f841-4520-877b-b2744e14a935n%40googlegroups.com.

Reply via email to