how to color circles on an image? the color should varies with the variation of the serial data

1 visualización (últimos 30 días)
i have a microcontroller connected to a force sensor and sending serial data. i'm putting these data in a matrix i need to draw circles to represent the force sensors on an image and color them the color should varies with the values of the serial data. example if the value in the matrix is 46 the color of the circle should varies from blue to red could someone help me please

Respuestas (3)

William Frane
William Frane el 1 de Ag. de 2014
A simple way to do this is to plot large circular data markers on top of the image (using the hold command). Something along the lines of:
% Display image
hold on
% Iterate through all the sensors
% Get position and color for each sensor
currentColor = ConvertValueToColor(currentSensorValue);
plot(currentX, currentY, 'Marker', 'o', 'MarkerSize', 30, 'MarkerFaceColor', currentColor, 'MarkerEdgeColor', 'none');
If you normalize your sensor data such that they lie between 0 and 1, you could use something like this to vary the color:
function out = ConvertValueToColor(in) % Picks a color between blue and red
% Assumes 'in' is between 0 and 1
out = (1-in)*[0 0 1] + in*[1 0 0];

Image Analyst
Image Analyst el 1 de Ag. de 2014
Another way is to use the rectangle() function to draw circles. Kind of crazy, but yes, rectangle() can draw circles(). I've always wondered why they just don't have a ellipse() or circle() function. But no, that would be too easy and intuitive.

marc kahwaji
marc kahwaji el 2 de Ag. de 2014
thanks for your help

Categorías

Más información sobre Images en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by