There is no automated way that I know that your plotted points change color depending on the color of the pixel behind them. Keep in mind that you do not need to use only eight predefined color specifications (ie “R” for red or “b” for blue). You can choose the RGB color specification for your plotted points, which is not usual for your main image. For example:
h = plot(0,0,'Marker','x','Color',[1 0.4 0.6]); %
You can programmatically find the least common color with some simple code that selects the least frequently used color values in the image. Here is one example:
rawData = imread('peppers.png'); %# Read a sample RGB image imData = reshape(rawData,[],3); %# Reshape the image data N = hist(double(imData),0:255); %# Create a histogram for the RGB values [minValue,minIndex] = min(N); %# Find the least used RGB values plotColor = (minIndex-1)./255; %# The color for the plotted points image(rawData); %# Plot the image hold on; hp = plot(500.*rand(1,20),350.*rand(1,20),... %# Plot some random points 'Marker','o','LineStyle','none',... 'MarkerFaceColor',plotColor,'MarkerEdgeColor',plotColor);
The above code first converts the image data into an M-3 matrix, where M is the number of image pixels, and the three columns contain the values of red, green, and blue, respectively. For each column, values are bitted using HIST , then the value with the lowest bin (i.e. the lowest frequency) is found for each column. These three values become the RGB triple for the plot color. When the image is superimposed on random dots of this color, it gives the following graph:

Please note that the code above selects a bright blue color for the graph points, which appears to be a color that does not appear on the image and thus gives good contrast.