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

4 Ansichten (letzte 30 Tage)
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( )
Input=im2double(imread('dataset/transport_clean.png'));
mask=im2double(imread('dataset/transport_mask.png'));
Q=mask(:,:,1);
R=Input(:,:,1);
G=Input(:,:,2);
B=Input(:,:,3);
X_red = Q.*R;
X_gre = Q.*G;
X_blu = Q.*B;
imshow(X_red);
end
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
untitled.jpg

Akzeptierte Antwort

Subhadeep Koley
Subhadeep Koley am 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');
end
maskOverImage.jpeg
  5 Kommentare
Subhadeep Koley
Subhadeep Koley am 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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by