Azzera filtri
Azzera filtri

How to get the pixel color values in one command?

3 visualizzazioni (ultimi 30 giorni)
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

Risposta accettata

Bruno Pop-Stefanov
Bruno Pop-Stefanov il 22 Gen 2014
Modificato: Bruno Pop-Stefanov il 22 Gen 2014
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 Commenti
Image Analyst
Image Analyst il 22 Gen 2014
For what it's worth, there's also an impixel() function.

Accedi per commentare.

Più risposte (1)

Walter Roberson
Walter Roberson il 22 Gen 2014
disp(reshape(Image, [], 3));

Categorie

Scopri di più su Image Processing Toolbox in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by