views:

48

answers:

2

I have:

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

How can I change colors of the histogram to Red, Green and Blue?
How can I change size of window tha appears?

EDIT:
Luis Miguel's answer regarding size of window works, but what if I want just to change height of window and left other parameneters (x, y, width) unchanged?

+1  A: 

You can change the color of the histogram bars and their limit lines as mentioned in MATLAB's reference, like this:

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

To change the window size by doing something like this:

h = figure(1);
set(h, 'Position', [x y width height])
Luis Miguel
Can you mix this with my code? I don't know how to do that...
Miko Kronn
It does not work for imhist. It works for hist. How can I do this?
Miko Kronn
You can try setting the size of the figure before actually plotting. Then when you plot it will occupy the figure window, I think.
Luis Miguel
+2  A: 

Size of the window:
You can get and then set 'Position'.

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);
Ichibann
You can do `pos(2)=max(pos(2)-10,0);` to prevent window's bottom to go out of screen.
yuk