In this functional example below, the colorbar value (cval) is set to 140.0 which is within the yellow-green spectrum of the colorbar. The tolerance (tol) is set to 0.5 meaning that any value within 140 +/- 0.5 is accepted. A tolerance of 0 only accepts exact matches which will likely fail.
The "CData" (color data) is pulled from the figure and the code identifies which coordinates are within tolerance to your selected color value. Black markers are plotted showing the matches.
figure()
A = [200 200 200 200 200; 200 200 200 200 200; 200 200 100 200 200; 200 200 200 200 200; 200 200 200 200 200];
Percent_matrix = flipud (A);
Percent_Interp = imresize(Percent_matrix,200,'bilinear');
pcolor(Percent_Interp)
shading interp
caxis([0 200])
colorbar();
cval = 140.0;
tol = .5;
ax = gca();
cdata = ax.Children.CData;
cidx = cdata >= (cval-tol) & cdata <= cval+tol;
x = ax.Children.XData;
y = ax.Children.YData;
[yidx,xidx] = find(cidx);
xSelect = x(xidx);
ySelect = y(yidx);
hold on
h = plot(xSelect, ySelect, 'ks', 'MarkerFaceColor', 'k','markersize', 2);
Best Answer