Display pixel colors from their known RGB values
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi. I would like to start from the known RGB values (in matrix) to visualize a colored figure.
In detail:
- I want to create a matrix with "black" pixels (see "matrix_zeros")
- on this "matrix_zeros" I want to substitute, instead of 0's, the RGB values found in "RGB_matrix" using the coordinates found in "coord_pixel"
- once the RGB matrix(es) are created, I want to be able to display it as a figure
RGB_matrix = load("RGB_matrix.mat");
RGB_matrix = RGB_matrix.REG_agg;
coord_pixel = load("coord_pixel.mat");
coord_pixel = coord_pixel.coord_pixel_ANA;
matrix_zeros = zeros(520);
0 commentaires
Réponse acceptée
DGM
le 16 Fév 2023
Here's one way.
load coord_pixel.mat
load RGB_matrix.mat
% since no geometry information is known,
% i'm just going to presume that information based on the range of coordinates
sz = [512 512]; % 512? 520?
% convert to linear indices
% i'm going to presume that coordinates are [y x]
idx = sub2ind(sz,coord_pixel_ANA(:,1),coord_pixel_ANA(:,2));
% create output image as a 3-column color table
% REG_agg is improperly-scaled double
% so just create the output in the proper class for the scale (uint8)
outpict = zeros([prod(sz) 3],'uint8');
% insert colors
outpict(idx,:) = REG_agg;
% reshape output
outpict = reshape(outpict,[sz 3]);
imshow(outpict)
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Interactive Control and Callbacks dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!