Borrar filtros
Borrar filtros

Converting a 2D image to a 1D variant

20 visualizaciones (últimos 30 días)
Tb
Tb el 23 de Feb. de 2022
Editada: Tb el 1 de Mzo. de 2022
I have an image and I want to find the RGB values of each index of the image, and then reshape the matrix such that the image is now a 1D array. Is there any way to do this? I have been playing around with the rgb2ind() command with no luck.
Thanks

Respuestas (1)

Image Analyst
Image Analyst el 24 de Feb. de 2022
Not sure what format you want but if you want all the red values then all the green values and then all the blue values you can do this:
[r,g,b] = imsplit(rgbImage);
vec = [r(:); g(:); b(:)];
If you want in a matrix with the x,y,r,g,b (one pixel per row), then see the attached code.

Categorías

Más información sobre Image Processing Toolbox en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by