How to get the pixel color values in one command?

I want to get the color pixel value in one line command or syntax.
I know we have to use get below syntax Red=Image(x,y,1); Green=Image(x,y,2); Blue=(Image(x,y,3);
But it make program too long.
I have to check the color of each pixel in image. So Is there any other syntax to get the specified pixel color range in one array.
I want the output like this
= 255 242 0

 採用された回答

Bruno Pop-Stefanov
Bruno Pop-Stefanov 2014 年 1 月 22 日
編集済み: Bruno Pop-Stefanov 2014 年 1 月 22 日

1 投票

Yes, the color is a vector of three values. To access the color of pixel (x,y), you can write:
color = squeeze( Image(x,y,:) );
and color will be a vector of length 3.
Thanks to Walter Roberson for suggesting using squeeze.
As Image Analyst noted in the comments, you can also use the impixel function.

3 件のコメント

saravanakumar D
saravanakumar D 2014 年 1 月 22 日
Yes it worked. but i din't get result as i want. I get this result
>> color=RGB(56,54,:); >> color
color(:,:,1) =
0
color(:,:,2) =
0
color(:,:,3) =
0
i wanna a matrix to compare with other colors. Like, Red=[237 28 36]; yellow=[255 242 0];
So i need same as this of matrix as result.
Walter Roberson
Walter Roberson 2014 年 1 月 22 日
squeeze(RGB(56,54,:))
Image Analyst
Image Analyst 2014 年 1 月 22 日
For what it's worth, there's also an impixel() function.

サインインしてコメントする。

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2014 年 1 月 22 日

0 投票

disp(reshape(Image, [], 3));

1 件のコメント

saravanakumar D
saravanakumar D 2014 年 1 月 22 日
i didn't understand this syntax. how it is working?

サインインしてコメントする。

カテゴリ

Community Treasure Hunt

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

Start Hunting!

Translated by