Add colorbar of colored plot on grayscale image
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Xiaozhun Tang
il 6 Mag 2019
Commentato: Xiaozhun Tang
il 7 Mag 2019
I have a grayscale image and draw a colored scatter plot on it,but the colorbar just vary from blcak to white,i wanna know how to show the colorbar of the scatter plot but not grayscale image.

0 Commenti
Risposta accettata
Bjorn Gustavsson
il 6 Mag 2019
Something like this:
% Assuming your grayscale image is: d in double format
grayscaleIM(:,:,3) = (d-min(d(:)))/(max(d(:))-min(d(:)));
grayscaleIM(:,:,2) = (d-min(d(:)))/(max(d(:))-min(d(:)));
grayscaleIM(:,:,1) = (d-min(d(:)))/(max(d(:))-min(d(:)));
figure
colormap(jet)
imagesc(x,y,grayscaleIM)
hold on
scatter(X,Y,23,V,'filled')
colorbar
Perhaps you have your data in some other formats but you can easily produce an RGB-image that only shows gray-scale or a binary black-white image regardless of what colourmap you use. Then the scatter-plot will work with the current colormap, as should the colorbar.
HTH
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!