2010-10-21 51 views
2

我:MATLAB:如何改变imhist的颜色和窗口大小?

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); 

我如何改变柱状图的颜色以红,绿,蓝?
如何更改出现的窗口大小?

编辑:
路易斯·马吉尔的有关窗口作品尺寸的答案,但如果我想只改变窗口的高度,离开其他parameneters(X,Y,宽度)不变的是什么?

+0

你可以找到这个答案的相关有色这个柱状图的例子:http://stackoverflow.com/questions/3961971/how-do-i-re-implement-a-color-based-histogram- do-feature-extraction-based-col/3962867#3962867 – Amro 2010-10-21 19:58:51

+0

这很好,但我必须使用imhist。 – 2010-10-21 22:32:34

+0

我刚刚意识到这是你的问题,对不起;) – Amro 2010-10-21 23:24:42

回答

4

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

要通过做这样的事情改变窗口大小窗口大小:
您可以获取并设置'位置'。

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); 
+3

你可以做'pos(2)= max(pos(2)-10,0);'以防止窗口底部离开屏幕。 – yuk 2010-10-21 23:54:37

2

可以更改柱状图和他们的极限线的颜色为MATLAB's reference提到的,像这样:

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

你可以混合这与我的代码?我不知道该怎么做... – 2010-10-21 18:58:00

+0

它不适用于imhist。它适用于hist。我怎样才能做到这一点? – 2010-10-21 19:27:09

+0

您可以在实际绘制之前尝试设置图形的大小。那么当你绘制它时会占据数字窗口,我想。 – 2010-10-22 01:43:36