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.
27 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Walter Roberson
2018-5-23
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 个评论
Image Analyst
2018-5-24
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Blue 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!