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.

7 ビュー (過去 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])

回答 (1 件)

Santhana Raj
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])

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by