Got Questions? Get Answers.
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:
extract all grey values

Subject: extract all grey values

From: Aron Sceidt

Date: 5 Oct, 2011 16:53:10

Message: 1 of 3

is there a proper matlab way to extract greys (white to black) from an image? Assuming white balance may be incorrect, which colour space will work best?

Subject: extract all grey values

From: ImageAnalyst

Date: 5 Oct, 2011 21:14:31

Message: 2 of 3

On Oct 5, 12:53 pm, "Aron Sceidt" <sigarr...@gmail.com> wrote:
> is there a proper matlab way to extract greys (white to black) from an image? Assuming white balance may be incorrect, which colour space will work best?

-----------------------------------------------------------------
Aron:
No. It depends on what you want to do. Usually you'll pick the
method that gives you the best contrast. I usually look at all 3
color channels and pick the best one:

% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);

but some people just use the built-in rgb2gray() which is slower and
gives you lower contrast than the best individual color channel. I
guess they just don't know how to pick out an individual color channel
or look at them to find the best one.

An even better way would be to use something like principal components
analysis to get the right rotation to give you the best combination of
values. Or one simple thing to do is to also look at the LAB and HSV
color spaces to see if one of those channels will give you what you
need. See my color segmentation demos at :
http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862
ImageAnalyst

Subject: extract all grey values

From: Aron Sceidt

Date: 6 Oct, 2011 06:25:28

Message: 3 of 3

thanks, i did try the hsv method, building a mask where saturation is beneath a certain value... I also tried constructing a 'box' in the rgb space linear from 0,0,0 to 255 255 255 and keeping values only inside of that box. Both methods work to some extent, but not 100% accurate and I wanted to know whether there are any other methods.

Both methods seem to suffer most because of incorrect white balance (probably because of the warm or cold tint added). So HSI might work better than HSV? I will give the link you sent me a look. Thanks a lot

 ImageAnalyst <imageanalyst@mailinator.com> wrote in message <7025371c-52a9-4d1c-8306-a59e1cc36bc2@db5g2000vbb.googlegroups.com>...
> On Oct 5, 12:53 pm, "Aron Sceidt" <sigarr...@gmail.com> wrote:
> > is there a proper matlab way to extract greys (white to black) from an image? Assuming white balance may be incorrect, which colour space will work best?
>
> -----------------------------------------------------------------
> Aron:
> No. It depends on what you want to do. Usually you'll pick the
> method that gives you the best contrast. I usually look at all 3
> color channels and pick the best one:
>
> % Extract the individual red, green, and blue color channels.
> redChannel = rgbImage(:, :, 1);
> greenChannel = rgbImage(:, :, 2);
> blueChannel = rgbImage(:, :, 3);
>
> but some people just use the built-in rgb2gray() which is slower and
> gives you lower contrast than the best individual color channel. I
> guess they just don't know how to pick out an individual color channel
> or look at them to find the best one.
>
> An even better way would be to use something like principal components
> analysis to get the right rotation to give you the best combination of
> values. Or one simple thing to do is to also look at the LAB and HSV
> color spaces to see if one of those channels will give you what you
> need. See my color segmentation demos at :
> http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862
> ImageAnalyst

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