Find the maximum value on each color dimension (red, green, or blue) and plot a circle using that color. There may be more than one pixel with a maximum value; if so, pick one pixel at random.
6 次查看(过去 30 天)
显示 更早的评论
*Find the maximum value on each color dimension (red, green, or blue) and plot a circle using that color. There may be more than one pixel with a maximum value; if so, pick one pixel at random.
For this task, I have imported a picture, added two annotations and subplotted each RGB component. However, I want to find the maximum value in each color dimension. I presume this number is a grayscale number, but I want to plot a circle with this color. *
%Import and plot picture of amsterdam
amsterdam = imread('amsterdam.bmp');
whos amsterdam;
imagesc(amsterdam)
hold on
plot ( [400 375], [75 325], 'r-d', 'linewidth', 4)
plot (375,480, 'm*','MarkerSize', 12)
title_color_components='RGB';
for subploti=1:4
subplot(2,2,subploti)
if subploti<4
imagesc(amsterdam(:,:,subploti))
title([ 'Plotting just the ' title_color_components(subploti) ' dimension.' ])
else
imagesc(amsterdam)
title('Plotting all colors')
end
end
max_red = max (max (amsterdam(:,:,1)));
max_green = max (max(amsterdam(:,:,2)));
max_blue = max (max(amsterdam(:,:,3)));
t = linspace(0,2*pi);
figure
plot(cos(t),sin(t), 'Color', [max_red max_green max_blue])
0 个评论
回答(1 个)
Santhana Raj
2017-5-31
The property color in plot function takes input between 0 to 1. While your max color values are >1 usually. Try the below one:
plot(cos(t),sin(t), 'Color', [max_red/255 max_green/255 max_blue/255])
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Line Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!