Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: The mixing formula of RGB
Replies: 6   Last Post: Jan 18, 2013 4:34 AM

 Messages: [ Previous | Next ]
 Steven Lord Posts: 18,038 Registered: 12/7/04
Re: The mixing formula of RGB
Posted: Jan 16, 2013 9:41 AM

"Wenlong " <scc.wwl@gmail.com> wrote in message
news:kd5vfh\$gcp\$1@newscl01ah.mathworks.com...
> Hi, Eugenijus
>
>
> I know little about computer graphic. My problem is that I need the pixel
> value of pixels in a colorized image (.BMP format), and use the value for
> some data analysis. I have the grayscale version of the same image, and I
> see it is a 2D matrix. So I can specify the coordinates of a pixel and get
> its pixel value.
>
> But when I come to colorized version of the image, it is a 3D matrix

The convention in MATLAB is that matrices are 2-D. Variables with arbitrary
numbers of dimensions are arrays. [All matrices are also arrays, but only
some arrays are matrices.] Certain operations are defined only on matrices
and will not work on N-D (N > 2) arrays. [Matrix multiplication is one
example.]

> that, as you said, combined by red, green and blue. I think there could be
> a way to extract the pixel value, not in three individual channels but a
> single metric?

img = rand(5, 4, 3);
pixel23 = img(2, 3, :)

The first element of pixel23 is the R component of the pixel at location (2,
3) in img. The second is the G component, the third if B.

--
Steve Lord
slord@mathworks.com
http://www.mathworks.com

Date Subject Author
1/14/13 Wenlong
1/14/13 Steven Lord
1/15/13 ejs@seniejitrakai.net
1/16/13 Wenlong
1/16/13 Steven Lord
1/18/13 Wenlong