Is there anyway to interactively change the color of a data point in an imagesc plot?

2 次查看(过去 30 天)
Say I had an imagesc plot and wanted to change one of the values from black to white. Is there anyway to do that in the plot itself, or is there any way to maybe use a GUI to allow the user to do that?
Here is the code for reference
nRows = 20;
nCols = 50;
Matrix = zeros(nRows,nCols);
Rndm = randi([0 1],size(Matrix));
imagesc(Rndm)
colormap(gca, gray)
  4 个评论
Walter Roberson
Walter Roberson 2020-1-25
Well, you could do it with techniques such as first converting your image to rgb using mat2gray() followed by im2uint8() followed by ind2rgb() . After that, you could use ginput() or similar to designate points you wanted to change the color of, and some kind of interface indicating the color you wanted to change to, and store the results in a matrix .

请先登录,再进行评论。

回答(1 个)

Alex Weaver
Alex Weaver 2020-1-28
That did the trick, thank you for the help!

类别

Help CenterFile Exchange 中查找有关 Colormaps 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by