我在MATLAB中有一张图片并将其分解为R,G和B通道。 现在我需要找出分辨率,中位数,上部 和 下部 < em> quartil , interquartil span 和 modus 。
以下是我使用的代码: 关闭所有; CLC;清除所有
I = imread('image_S006_I0000.jpg');
imshow(I)
[R S T] = size(I);
Red(:,:,1)=I(:,:,1);
Red(:,:,2)=zeros(R,S);
Red(:,:,3)=zeros(R,S);
Green(:,:,1)=zeros(R,S);
Green(:,:,2)=I(:,:,1);
Green(:,:,3)=zeros(R,S);
Blue(:,:,1)=zeros(R,S);
Blue(:,:,2)=zeros(R,S);
Blue(:,:,3)=I(:,:,1);
OR
Red=double(I(:,:,1));
Red=zeros(R,S);
Red=zeros(R,S);
Green=zeros(R,S);
Green=double(I(:,:,1));
Green=zeros(R,S);
Blue=zeros(R,S);
Blue=zeros(R,S);
Blue=double(I(:,:,1));
OR
Red(:,:,1)=double(I(:,:,1));
Green(:,:,1)=double(I(:,:,1));
Blue(:,:,1)=double(I(:,:,1));
cat(3, uint8(Red), zeros(R, S), zeros(R, S));
others = zeros(R, S);
red_plt = cat(3, uint8(Red), others, others);
green_plt = cat(3, others, uint8(Green), others);
blue_plt = cat(3, others, others, uint8(Blue));
figure()
subplot(131);imshow(red_plt)
subplot(132);imshow(green_plt)
subplot(133);imshow(blue_plt)
NOW PLOTTITG (It doesn't print it in Red, Green and Blue color. First two
are just all black, the third one is black and white):
figure()
subplot(131);imshow(uint8(Red))
subplot(132);imshow(uint8(Green))
subplot(133);imshow(uint8(Blue))
[x1 y1 z1] = size(I);
% MEDIAN.
imgmedianR = median (Red(:))
imgmedianG = median (Green(:))
imgmedianB = median (Blue(:))
%QUARTIL
r025 = quantile(Red,0.25)
r075 = quantile(Red,0.75)
g025 = quantile(Green,0.25)
g075 = quantile(Green,0.75)
b025 = quantile(Blue,0.25)
b075 = quantile(Blue,0.75)
%INTERQUARTIL SPAN
r_iqr = iqr(Red)
g_iqr = iqr(Green)
b_iqr = iqr(Blue)
modus_Red = mode(Red(:))
modus_Green = mode(Green(:))
modus_Blue = mode(Blue(:))
MEDIAN:当我尝试计算MEDIAN时,它给了我一堆数字(实际上matlab分别打印出每列的数字)。 那我做错了什么?
QUARTIL:与我在MEDIAN的代码中遇到的问题相同。那我做错了什么?
INTERQUARTIL SPAN:Matlab打印出后续错误: 不支持混合整数类输入。 我做错了什么?
解决方案:我需要使用Matlab找出图像的分辨率。我已经尝试了funciton imfinfo ,但信息并未包括在内。如何使用任何类型的Matlab函数找到这样的信息?
非常感谢您提前!