getting RGB from image created with imagesc
9 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
ariel
am 15 Mär. 2016
Kommentiert: Image Analyst
am 16 Mär. 2016
Hi. I am creating am image of a matrix using imagesc.
i want to get the RGB values of every pixel in the image.
I tried using get(im,'CData'), but it gives back the matrix that created the image.
how can do it?
thanks, Ariel
0 Kommentare
Akzeptierte Antwort
Mike Garrity
am 15 Mär. 2016
Bearbeitet: Mike Garrity
am 15 Mär. 2016
You probably want ind2rgb. But if you're using imagesc, rather than image, you're probably need to scale your color values. It looks something like this:
v = ??; % my matrix
map = colormap;
minv = min(v(:));
maxv = max(v(:));
ncol = size(map,1);
s = round(1+(ncol-1)*(v-minv)/(maxv-minv));
rgb_image = ind2rgb(s,map);
If you have integer color values, then you don't need to do that scaling before calling ind2rgb.
1 Kommentar
Weitere Antworten (1)
Image Analyst
am 15 Mär. 2016
imagesc() does not create images - it displays them. So you already have the image. If you want it pseudocolored, look up colormap in the help - there are a variety of predefined colormaps to choose from: hot, winter, jet, parula, etc. Pick one that you like and use ind2rgb to create a pseudocolored RGB image from your gray scale image.
% Use hsv color map to create an RGB image from a gray scale image:
rgbImage = ind2gray(grayImage, hsv(256));
2 Kommentare
Image Analyst
am 16 Mär. 2016
Yes. If you want some certain amount, specify it. Like if you want 1000 colors, say jet(1000).
Siehe auch
Kategorien
Mehr zu Red finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
