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:
Pixels to matrix

Subject: Pixels to matrix

From: Mohammad

Date: 24 Aug, 2013 09:31:08

Message: 1 of 2

Hi,
Can anyone tell me how to convert a pixel in an image into a matrix form?
Thanks.

Subject: Pixels to matrix

From: Sadik

Date: 25 Aug, 2013 00:34:10

Message: 2 of 2

Hi Mohammad,

Could you be more specific? For instance, would you like to put the three RGB values in a vector? If so, you could do the following:

% Assuming that I is the H*W*3 RGB image matrix you read from a file [possibly using imread()], the RGB values for the pixel (xP,yP) would be:

% I am setting xP and yP arbitrarily here.
xP = 45;
yP = 105;
% v will hold the RGB values: v = [R G B]
v = squeeze(I(yP,xP,:));

Best.

Tags for 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