How can I index color bar values from an image generated using Matlab imagesc? I want to be able to index them in the command window.
22 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I created a range plot using the matlab command
where G is range data
figure
colormap(jet)
imagesc(20*log10(abs(G)))
xlabel('No. of Sweeps')
ylabel('Range')
title('Range Profiles')
clim = get(gca,'CLim');
set(gca, 'CLim', clim(2)+[-40,0]);
colorbar
axis xy
The image created in colomarp has associated color bar values for each pixel in the image. I want to be able to index row element/pixels using the matlab command and use their associated colobar value instead of the actual pixel value.
Thanks
0 comentarios
Respuestas (1)
Walter Roberson
el 23 de Mayo de 2018
mat2gray() to do the equivalent of imagesc's mapping between minimum and maximum value. im2uint8() to transform to uint8. Then use ind2rgb.
Or use histc() or histcounts() to transform values to bin numbers, and use the bin numbers to index the colormap. Or just map.
cmap = jet;
mapped_data = 20*log10(abs(G));
min_mapped = min(mapped_data(:));
max_mapped = max(mapped_data(:));
ind = ceil((mapped_data - min_mapped) .* (max_mapped - min_mapped) * size(cmap,1));
ind(ind == 0) = 1;
RGB = cmap(ind, :);
4 comentarios
Martins Ezuma
el 23 de Mayo de 2018
Editada: Walter Roberson
el 24 de Mayo de 2018
Image Analyst
el 24 de Mayo de 2018
Not exactly sure what "how do I know which pixel i am indexing by just looking at the image?" means, but you can see the pixel value at a particular (x,y) location in an image by using ginput(1), impixelinfo(), or imtool(). With the intensity or index, and caxis() and the colormap() you can also get the RGB color the index/intensity is mapped to.
Ver también
Categorías
Más información sobre Blue en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!