how to add color to certain areas of a .png image?

5 visualizzazioni (ultimi 30 giorni)
Hi all, i have been given a black and white image of a race track with 16 points marked on it. im supposed to mark these points with a red dot. how can i do this?
thank you in advance
  2 Commenti
Geoff Hayes
Geoff Hayes il 29 Mar 2015
Tash - do you know the coordinates of these 16 points, or are you supposed to determine the points using an algorithm? Please clarify your question.
If you know the points/coordinates, then you could use
plot(X,Y,'ro')
which will plot a red circle given the coordinates defined in the X and Y arrays.
Tash Dee
Tash Dee il 29 Mar 2015
hi Geoff, no im supposed to find the coordinates using an algorithm.

Accedi per commentare.

Risposta accettata

Image Analyst
Image Analyst il 29 Mar 2015
Do you want to add color to an area (like your subject says), or to points (like the body of your question says)? If it's to points, just use
plot(x,y,'r.', 'MarkerSize', 50);
Or if it's to areas, see my attached demos.
  5 Commenti
Image Analyst
Image Analyst il 29 Mar 2015
It's not too hard. See my Image Segmentation Tutorial http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862. Basically these are the steps:
  1. threshold the image: binaryImage = grayImage > 128
  2. label the image with bwlabel
  3. measure the blobs with regionprops - get area, perimeter, and centroid
  4. size filter the blobs to get blobs of only the size of the small white spots.
  5. Get rid of the spots in the numbers 6, 8, 9, and 10 by finding the larger round blobs and filling them in.
  6. If you want the red spots in the overlay, use plot.
  7. If you want an RGB image, then create separate R, G, and B color channels, and then use cat() to create an RGB image of just the spot

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by