【问题标题】:MATLAB: How to change color of imhist and size of window?MATLAB:如何更改 imhist 的颜色和窗口的大小?
【发布时间】:2011-04-28 19:00:48
【问题描述】:

我有:

img = imread('pic.jpg','jpg');
r = img(:,:,1);
g = img(:,:,2);
b = img(:,:,3);

subplot(3,1,1);
imhist(r);
subplot(3,1,2);
imhist(g);
subplot(3,1,3);
imhist(b);

如何将直方图的颜色更改为红色、绿色和蓝色?
如何更改出现的窗口大小?

编辑:
Luis Miguel 关于窗口大小的回答有效,但是如果我只想改变窗口的高度而保持其他参数(x、y、宽度)不变呢?

【问题讨论】:

标签: image matlab histogram


【解决方案1】:

窗口大小:
您可以获取然后设置“位置”。

pos = get(h,'Position');
pos(4) = pos(4) + 10; % changing height only
pos(2) = pos(2) - 10; % you probably would want that - just try
set(h, 'Position', pos);

【讨论】:

  • 你可以做pos(2)=max(pos(2)-10,0);来防止窗口底部走出屏幕。
【解决方案2】:

您可以更改直方图条的颜色及其限制线,如MATLAB's reference 中所述,如下所示:

h = findobj(gca,'Type','patch');
set(h,'FaceColor','r','EdgeColor','w')

通过执行以下操作更改窗口大小:

h = figure(1);
set(h, 'Position', [x y width height])

【讨论】:

  • 它不适用于 imhist。它适用于组织。我该怎么做?
  • 您可以在实际绘图之前尝试设置图形的大小。然后当你绘制它会占据图形窗口,我想。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-10-15
  • 1970-01-01
  • 2015-07-03
  • 2022-01-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多