Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
can we get the rgb image after multiply with binary image

Subject: can we get the rgb image after multiply with binary image

From: MANISH KUMAR SHARMA

Date: 3 Nov, 2010 09:43:03

Message: 1 of 7

can we get the rgb image after multiplying with binary image ?????
or, using 'and' operation with rgb image with binary image????????
or, using masking n tell me how?????????
Plz write the code for that
thanx


manish sharma
manisharma2009@gmail.com

Subject: can we get the rgb image after multiply with binary image

From: ImageAnalyst

Date: 3 Nov, 2010 11:21:53

Message: 2 of 7

% Mask image must be converted to the same integer type
% as the integer image we want to mask.
mask = cast(binaryImage, class(rgbImage));

% Extract the individual red, green, and blue color planes.
redPlane = rgbImage(:, :, 1);
greenPlane = rgbImage(:, :, 2);
bluePlane = rgbImage(:, :, 3);

% Do the masking.
maskedRed = redPlane .* mask;
maskedGreen = greenPlane .* mask;
maskedBlue = bluePlane .* mask;

% Combine back into a masked RGB image.
maskedRgbImage = cat(3, maskedRed, maskedGreen, maskedBlue);

Subject: can we get the rgb image after multiply with binary image

From: Sean

Date: 3 Nov, 2010 12:32:07

Message: 3 of 7

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <29b1855d-9815-4dc5-b0ff-a54d69cb0911@x42g2000yqx.googlegroups.com>...
> % Mask image must be converted to the same integer type
> % as the integer image we want to mask.
> mask = cast(binaryImage, class(rgbImage));
>
> % Extract the individual red, green, and blue color planes.
> redPlane = rgbImage(:, :, 1);
> greenPlane = rgbImage(:, :, 2);
> bluePlane = rgbImage(:, :, 3);
>
> % Do the masking.
> maskedRed = redPlane .* mask;
> maskedGreen = greenPlane .* mask;
> maskedBlue = bluePlane .* mask;
>
> % Combine back into a masked RGB image.
> maskedRgbImage = cat(3, maskedRed, maskedGreen, maskedBlue);

or
maskedRgbImage = bsxfun(@times,rgbImage,cast(mask,class(rgbImage)))

Subject: can we get the rgb image after multiply with binary image

From: Suraj

Date: 17 Feb, 2013 04:56:16

Message: 4 of 7

Hi When i execute the code which u mentioned, it gives me the following error.

??? Error using ==> times
Matrix dimensions must agree.

the error is with these lines.

maskedRed = redPlane .* mask;
maskedGreen = greenPlane .* mask;
maskedBlue = bluePlane .* mask;


Whats happening?

Subject: can we get the rgb image after multiply with binary image

From: Image Analyst

Date: 17 Feb, 2013 15:30:07

Message: 5 of 7

Suraj
Your mask is a different size than your images. Do this, before you try to multiply them, and you'll find out why:

[rows columns numberOfColorChannels] = size(redPlane);
[rows columns numberOfColorChannels] = size(mask);
whos redPlane
whos mask

Subject: can we get the rgb image after multiply with binary image

From: Suraj

Date: 18 Feb, 2013 04:15:08

Message: 6 of 7

"Image Analyst" wrote in message <kfqt1v$bf8$1@newscl01ah.mathworks.com>...
> Suraj
> Your mask is a different size than your images. Do this, before you try to multiply them, and you'll find out why:
>
> [rows columns numberOfColorChannels] = size(redPlane);
> [rows columns numberOfColorChannels] = size(mask);
> whos redPlane
> whos mask

Thank you very much for the quick response. I corrected the bug and its working perfectly fine now. I am new to matlab so pardon the simplicity of my question. Thanks again.

Subject: can we get the rgb image after multiply with binary image

From: V PADMAJA

Date: 26 May, 2014 13:57:10

Message: 7 of 7

"Suraj" wrote in message <kfs9sb$1iq$1@newscl01ah.mathworks.com>...
> "Image Analyst" wrote in message <kfqt1v$bf8$1@newscl01ah.mathworks.com>...
> > Suraj
> > Your mask is a different size than your images. Do this, before you try to multiply them, and you'll find out why:
> >
> > [rows columns numberOfColorChannels] = size(redPlane);
> > [rows columns numberOfColorChannels] = size(mask);
> > whos redPlane
> > whos mask
>
> Thank you very much for the quick response. I corrected the bug and its working perfectly fine now. I am new to matlab so pardon the simplicity of my question. Thanks again.

Hi..
I'm too getting the same error after applying the codes given by you... I'm new to matlab. please help me torectify the errors.

thanx

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us