图像处理基础基于matlab图像RGB+HSV分布图含Matlab源码 234期

Posted 紫极神光

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了图像处理基础基于matlab图像RGB+HSV分布图含Matlab源码 234期相关的知识,希望对你有一定的参考价值。

一、获取代码方式

获取代码方式1:
完整代码已上传我的资源:【图像处理基础】基于matlab图像RGB+HSV分布图【含Matlab源码 234期】

获取代码方式2:
通过订阅紫极神光博客付费专栏,凭支付凭证,私信博主,可获得此代码。

备注:
订阅紫极神光博客付费专栏,可免费获得1份代码(有效期为订阅日起,三天内有效);

二、数字图像处理简介

图像处理基础教程链接
1 【基础教程】基于matlab图像处理(表示方法+数据结构+基本格式+类型转换+读取+点运算+代数运算)【含Matlab源码 834期】
2 【基础教程】基于matlab图像处理(读写+显示+运算+转换+变换+增强+滤波+分析+统计)【含Matlab源码 144期】
3 【基础教程】基于matlab图像增强+复原+分割【含Matlab源码 056期】

三、部分源代码

im = imread('test_image/ms.jpg');
%% RGB Distribution, cube
rgb_distribution(im,'cube',5)
%% RGB Distribution, sphere
rgb_distribution(im,'sphere',5)
%% HSV Distribution
hsv_distribution(im,5)
function hsv_distribution(im,amp)
% hsv_distribution(im,amp)
%  This function computes and visualizes the HSV distribution (or
%  histogram) of an image.
%  The volume of each volume element is proportion to the percentage of the
%  correspondent HSV value.
%  Input arguments:
%   im, the input image;
%   amp, amplification factor, the maximum radius of any volume element
%   (sphere) is 1/vstep/2*amp.
%  

if nargin < 2
    amp = 3;
end
imhsv = rgb2hsv(im);
hstep = 2; %degree
sstep = 0.05;
vstep = 0.1;
nh = 360/hstep;
ns = 1/sstep;
nv = 1/vstep;
[M,N,~] = size(im);
%% count
cnt = zeros(nh,ns,nv);
maxcnt = -inf;
for k1 = 1:M
    for k2 = 1:N
        idxh = max(ceil(imhsv(k1,k2,1)*360/hstep),1);
        idxs = max(ceil(imhsv(k1,k2,2)/sstep),1);
        idxv = max(ceil(imhsv(k1,k2,3)/vstep),1);
        cnt(idxh,idxs,idxv) = cnt(idxh,idxs,idxv)+1;
        if cnt(idxh,idxs,idxv) > maxcnt
            maxcnt = cnt(idxh,idxs,idxv);
        end
    end
end
%% plot
h_f = figure('name','HSV Distribution','numbertitle','off','color',[1 1 1]*1);
h_a = axes('parent',h_f);
set(h_a,'box','on','projection','perspective','dataaspectratio',[1 1 1])
set(h_a,'xlim',[-1 1],'ylim',[-1 1],'zlim',[0 1])
set(h_a,'xtick',[],'ytick',[])
set(h_a,'xgrid','on','ygrid','on','zgrid','on')
[sphx,sphy,sphz] = sphere(16);
for k1 = 1:nh
    for k2 = 1:ns
        for k3 = 1:nv
            ch = (k1-0.5)*hstep;
            cs = (k2-0.5)*sstep;
            cv = (k3-0.5)*vstep;
            [cx,cy,cz] = pol2cart(ch/180*pi,cs,cv);
            [cr,cg,cb] = hsv2rgb([ch/360,cs,cv]);
            if cnt(k1,k2,k3) > 0
                rcube = nthroot(cnt(k1,k2,k3)/maxcnt,3)*sstep/2*amp;
                surface(rcube*sphx+cx,rcube*sphy+cy,rcube*sphz+cz,...
                    'FaceColor',[cr cg cb],'FaceAlpha',0.9,...
                    'linestyle','none','parent',h_a);
            end
        end
    end
end

四、运行结果



五、matlab版本及参考文献

1 matlab版本
2014a

2 参考文献
[1] 蔡利梅.MATLAB图像处理——理论、算法与实例分析[M].清华大学出版社,2020.
[2]杨丹,赵海滨,龙哲.MATLAB图像处理实例详解[M].清华大学出版社,2013.
[3]周品.MATLAB图像处理与图形用户界面设计[M].清华大学出版社,2013.
[4]刘成龙.精通MATLAB图像处理[M].清华大学出版社,2015.
[5]陈浩,方勇,朱大洲,王成,陈子龙.基于蚁群算法的玉米植株热红外图像边缘检测[J].农机化研究. 2015,37(06)

以上是关于图像处理基础基于matlab图像RGB+HSV分布图含Matlab源码 234期的主要内容,如果未能解决你的问题,请参考以下文章

图像识别基于HSV和RGB模型水果分类matlab源码含 GUI

matlab图像处理内存不足怎么办?

paper 74:MATLAB图像处理_HSV与RGB颜色空间互转

水果识别基于RGB+HSV实现水果成熟度分级系统matlab源码含GUI

rgb转化到hsv图像外观会变吗opencv

基于内容的图像检索的直方图比较。不同的色彩空间(RGB、HSV 等)