how to color circles on an image? the color should varies with the variation of the serial data
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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
0 Commenti
Risposte (3)
William Frane
il 1 Ago 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];
0 Commenti
Image Analyst
il 1 Ago 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.
0 Commenti
Vedere anche
Categorie
Scopri di più su Visual Exploration in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!