E_l*_*ner 17 matlab image histogram
我用matlab读取了一个图像
input = imread ('sample.jpeg');
Run Code Online (Sandbox Code Playgroud)
然后我做
imhist(input);
Run Code Online (Sandbox Code Playgroud)
它给出了这个错误:
??? Error using ==> iptcheckinput
Function IMHIST expected its first input, I or X, to be two-dimensional.
Error in ==> imhist>parse_inputs at 275
iptcheckinput(a, {'double','uint8','logical','uint16','int16','single'}, ...
Error in ==> imhist at 57
[a, n, isScaled, top, map] = parse_inputs(varargin{:});
Run Code Online (Sandbox Code Playgroud)
运行后size(input),我看到我的输入图像很大300x200x3.我知道第三个维度是用于颜色通道,但有没有办法显示这个直方图?谢谢.
bla*_*bla 28
imhist显示灰度或二进制图像的直方图.使用rgb2gray在图像上,或者使用imhist(input(:,:,1))看到信道的一个在一个时间(红在这个例子中).
或者你可以这样做:
hist(reshape(input,[],3),1:max(input(:)));
colormap([1 0 0; 0 1 0; 0 0 1]);
Run Code Online (Sandbox Code Playgroud)
同时显示3个频道......
Phi*_*ann 13
我想在一个图中绘制红色,绿色和蓝色的直方图:
%Split into RGB Channels
Red = image(:,:,1);
Green = image(:,:,2);
Blue = image(:,:,3);
%Get histValues for each channel
[yRed, x] = imhist(Red);
[yGreen, x] = imhist(Green);
[yBlue, x] = imhist(Blue);
%Plot them together in one plot
plot(x, yRed, 'Red', x, yGreen, 'Green', x, yBlue, 'Blue');
Run Code Online (Sandbox Code Playgroud)
小智 5
histogarm图将具有强度级别的像素数.你的是一个rgb图像.所以你首先需要将它转换为强度图像.
这里的代码是:
input = imread ('sample.jpeg');
input=rgb2gray(input);
imhist(input);
imshow(input);
Run Code Online (Sandbox Code Playgroud)
您将能够获得图像的直方图.