Assigning property/value to image color, Oklahoma state
1 次查看(过去 30 天)
显示 更早的评论
Hello,
I have a very simple image (attached) that has white background and several filled circles of different colors. I am interested in the part of the image that is inside the line boundary (approximate boundaries for Oklahoma state). How can create matrices/grids that will have different numbers based on the color of the circles. For instance, the matrix/grid for red circles (color) should have value 5 for red color and 0 for whatever is not red; green should have 3 inside and 0 outside, etc.
Thanks, DjR
3 个评论
Image Analyst
2015-3-28
Attach your original image and what you want your output indexed image to look like. And why do I need a grid?
采纳的回答
Chad Greene
2015-3-30
Assuming you have data in x and y coordinates (switch x and y with lon and lat, if you're using geocoordinates), start by preallocating some empty matrix the size of your full x,y grid:
MyMap = zeros(mapheightpx,mapwidthpx);
where mapheightpx and mapwidthpx are the size of the categorical data map you'll be creating. Set red circle areas to 5 and green to 3:
red = inpolygon(gridx,gridy,redcircleoutlinex,redcircleoutliney);
MyMap(red) = 5;
green = inpolygon(gridx,gridy,greencircleoutlinex,greencircleoutliney);
MyMap(green) = 3;
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!