Sange
Sange

Reputation: 133

Overlaying images get dimmer

My problem is the following. I have one "background" picture (BF) and I want to overlay the Contour line of some bacteria I already identified (CT). I want to do it such that BF remain in grayscale and CT in some color. Both are in '.png' format

I succeed to do that, but the background get darker, and as I would like add 2/3 separate CT with different colors, in order to identify different sub-populations, things get worse. Could someone help me?!?!

BF

background - BF

CT

Contour line - CT

Fuse

Fused

BF = imread(filename_BF);
CT = imread(filename_CT);
CT2 = cat(3, zeros(size(CT)), CT, zeros(size(CT)));

X = imfuse(CT2, BF, 'blend');
imwrite(Fuse, filename_Fuse);

Code is very simple. It is as if when the images are fused, where the CT is 0 the background BF is subtracted a bit. What I want is just to have green lines from CT map over BF.

Thank you in advance.

Upvotes: 1

Views: 48

Answers (1)

Steffen
Steffen

Reputation: 2431

You can create the image by hand. I assume BF is three channel and CT Background is 0 and CT is one channel.

X = BF;
[r,c] = find(CT>0);
X(sub2ind(size(X),r,c,ones(size(r))*1)) = 0;
X(sub2ind(size(X),r,c,ones(size(r))*2)) = 255;
X(sub2ind(size(X),r,c,ones(size(r))*3)) = 0;
imshow(X);

Result:

enter image description here

Upvotes: 2

Related Questions