how to plot histogram of hue value in polar ?
6 ビュー (過去 30 日間)
古いコメントを表示
Hi
i wants to plot a histogram of hue values in polar . in my 1st image i have plotted histogram of hue values . and now i would like to plot it on polar as shown in figure 2.
please help me .
0 件のコメント
採用された回答
Image Analyst
2013 年 11 月 12 日
I just adapted Doug's code to use a sample image and I got this:
See code attached below in blue text.
2 件のコメント
その他の回答 (2 件)
Doug Hull
2013 年 11 月 11 日
編集済み: Doug Hull
2013 年 11 月 11 日
clear
clc
clf
z = peaks(300);
r = z(:,150);
r = r-min(r);
r = r/max(r);
n = numel(r)
cmap = jet(n)
drawWheel(r*0.8,cmap)
Save this file first though:
function drawWheel(r, cmap)
if (any(r > 1) | any(r < 0))
error('R must be a vector of values between 0 and 1')
end
if numel(r) ~= size(cmap,1)
error('Length of r and cmap must be the same')
end
n = numel(r);
innerRadius = 80;
outerRadius = 100;
angles = linspace(0,2*pi,n+1);
newR = innerRadius*(1-r);
for i = 1:n;
drawSpoke(innerRadius, outerRadius, angles(i), angles(i+1), cmap(i,:))
drawSpoke(newR(i) , innerRadius, angles(i), angles(i+1), cmap(i,:))
end
line(0,0,'marker','o')
line(cos(angles)*outerRadius, sin(angles)*outerRadius, 'LineWidth', 3, 'Color', 'k')
line(cos(angles)*innerRadius, sin(angles)*innerRadius, 'LineWidth', 3, 'Color', 'k')
axis equal
function h = drawSpoke(ri,ro,thetaStart,thetaEnd,c)
xInnerLeft = cos(thetaStart) * ri;
xInnerRight = cos(thetaEnd) * ri;
xOuterLeft = cos(thetaStart) * ro;
xOuterRight = cos(thetaEnd) * ro;
yInnerLeft = sin(thetaStart) * ri;
yInnerRight = sin(thetaEnd) * ri;
yOuterLeft = sin(thetaStart) * ro;
yOuterRight = sin(thetaEnd) * ro;
X = [xInnerLeft, xInnerRight, xOuterRight xOuterLeft];
Y = [yInnerLeft, yInnerRight, yOuterRight yOuterLeft];
h = patch(X,Y,c);
set(h,'edgeColor', 'none')
参考
カテゴリ
Help Center および File Exchange で Red についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!