【图像处理基础】基于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
  
 - 1
 - 2
 - 3
 - 4
 - 5
 - 6
 - 7
 - 8
 - 9
 - 10
 - 11
 - 12
 - 13
 - 14
 - 15
 - 16
 - 17
 - 18
 - 19
 - 20
 - 21
 - 22
 - 23
 - 24
 - 25
 - 26
 - 27
 - 28
 - 29
 - 30
 - 31
 - 32
 - 33
 - 34
 - 35
 - 36
 - 37
 - 38
 - 39
 - 40
 - 41
 - 42
 - 43
 - 44
 - 45
 - 46
 - 47
 - 48
 - 49
 - 50
 - 51
 - 52
 - 53
 - 54
 - 55
 - 56
 - 57
 - 58
 - 59
 - 60
 - 61
 - 62
 - 63
 - 64
 - 65
 - 66
 - 67
 - 68
 - 69
 
四、运行结果

 
 
五、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)
文章来源: qq912100926.blog.csdn.net,作者:海神之光,版权归原作者所有,如需转载,请联系作者。
原文链接:qq912100926.blog.csdn.net/article/details/122224349
- 点赞
 - 收藏
 - 关注作者
 
            
           
评论(0)