MATLAB Answers

Apply mask to RGB image. If mask is RGB as well do i have to seperet the mask to its channels too?

10 views (last 30 days)
fadams18 on 1 Feb 2020
Commented: fadams18 on 1 Feb 2020
Hello I want to apply this mask onto this RGB color to use in NMF
transport_mask.png ... transport_clean.png transport_input.png
function [ R, B,G ] = Split_Image( )
X_red = Q.*R;
X_gre = Q.*G;
X_blu = Q.*B;
So I want to inprint the left image on the right image to get an output in the third image.
How ever in my case i will have a red blue green channel with the masks.
I will then process these 3 images seperately using nmf and combine them after to reconstuct the original image
How ever when i run my code i get the same image below for all channels. What am i doing wrongly


Sign in to comment.

Accepted Answer

Subhadeep Koley
Subhadeep Koley on 1 Feb 2020
Hi, refer the code below.
function [ R, B, G ] = Split_Image()
input = im2double(imread('transport_clean.png'));
figure; imshow(input, []); title('Input image');
mask = imcomplement(im2double(rgb2gray(imread('transport_mask.png'))));
added = input + mask *0.3;
R = added(:, :, 1);
G = added(:, :, 2);
B = added(:, :, 3);
figure; imshow(added, []); title('Mask over the input image');


Show 2 older comments
fadams18 on 1 Feb 2020
Last point please, Im confused on how u added the mask. you did
Input + mask
Im used to
mask .* input
Whats the difference please.
Subhadeep Koley
Subhadeep Koley on 1 Feb 2020
Yes, you're used to multiply the mask with the input. However, in my code I have used a technique called Alpha Blending. I have added the mask with the input image where, the mask is modulated with a Alpha (0.3 in this case) value.
If you increase the Alpha value then, the text will be more prominent in the resulting image.

Sign in to comment.

More Answers (0)

Translated by