function [cg,theta] = cgmo(im,radius,norient,varargin)
% function [cg] = cgmo(im,radius,norient,...)
%
% Compute the color gradient at a single scale and multiple
% orientations.
%
% INPUT
% im Grayscale or RGB image, values in [0,1].
% radius Radius of disc for cg.
% norient Number of orientations for cg.
% 'nbins' Number of bins; should be > 1/sigmaSim.
% 'sigmaSim' For color similarity function.
% 'gamma' Gamma correction for LAB [2.5].
% 'smooth' Smoothing method, one of
% {'gaussian','savgol','none'}, default 'none'.
% 'sigmaSmo' Sigma for smoothing, default to radius.
%
% OUTPUT
% cg Size [h,w,d,norient] array of cg images,
% where d is the dimensionality of the image.
%
% The input parameters {radius,nbins,sigmaSim,sigmaSmo} should be
% scalars when the input image is grayscale, and can be either scalars
% or 3-element vectors when the image is RGB.
%
% See also cgmo.
%
% David R. Martin <dmartin@eecs.berkeley.edu>
% April 2003
% process options
nbins = 32;
sigmaSim = 0.1;
gamma = 2.5;
smooth = 'none';
sigmaSmo = radius;
for i = 1:2:numel(varargin),
opt = varargin{i};
if ~ischar(opt), error('option names not a string'); end
if i==numel(varargin), error(sprintf('option ''%s'' has no value',opt)); end
val = varargin{i+1};
switch opt,
case 'nbins', nbins=val;
case 'sigmaSim', sigmaSim=val;
case 'gamma', gamma=val;
case 'smooth',
switch val,
case {'none','gaussian','savgol'}, smooth=val;
otherwise, error(sprintf('invalid option smooth=''%s''',val));
end
case 'sigmaSmo', sigmaSmo=val;
otherwise, error(sprintf('invalid option ''%s''',opt));
end
end
% check arguments
if ndims(im)==2, % grayscale image
if numel(radius)~=1, error('radius should have 1 element'); end
if numel(nbins)~=1, error('nbins should have 1 element'); end
if numel(sigmaSim)~=1, error('sigmaSim should have 1 element'); end
if numel(sigmaSmo)~=1, error('sigmaSim should have 1 element'); end
elseif ndims(im)==3, % RGB image
if numel(radius)==1, radius = radius*ones(3,1); end
if numel(nbins)==1, nbins = nbins*ones(3,1); end
if numel(sigmaSim)==1, sigmaSim = sigmaSim*ones(3,1); end
if numel(sigmaSmo)==1, sigmaSmo = sigmaSmo*ones(3,1); end
if numel(radius)~=3, error('radius should have 1 or 3 elements'); end
if numel(nbins)~=3, error('nbins should have 1 or 3 elements'); end
if numel(sigmaSim)~=3, error('sigmaSim should have 1 or 3 elements'); end
if numel(sigmaSmo)~=3, error('sigmaSmo should have 1 or 3 elements'); end
radius = radius(:);
nbins = nbins(:);
sigmaSim = sigmaSim(:);
sigmaSmo = sigmaSmo(:);
else
error('image not of valid dimension');
end
norient = max(1,norient);
nbins = max(1,nbins);
% min and max values for a,b channels of LAB
% used to scale values into the unit interval
abmin = -73;
abmax = 95;
% make sure nbins is large enough with respect to sigmaSim
if any( nbins < 1./sigmaSim ),
warning('nbins < 1/sigmaSim is suspect');
end
% check pixel valies
if min(im(:)) < 0 | max(im(:))>1,
error('pixel values out of range [0,1]');
end
if ndims(im)==2, % grayscale image
% compute cg from gray values
cmap = max(1,ceil(im*nbins));
csim = colorsim(nbins,sigmaSim);
[cg,theta] = tgmo(...
cmap,nbins,radius,norient,...
'tsim',csim,'smooth',smooth,'sigma',sigmaSmo);
else, % RGB image
% convert gamma-corrected image to LAB and scale values into [0,1]
lab = RGB2Lab(im.^gamma);
lab(:,:,1) = lab(:,:,1) ./ 100;
lab(:,:,2) = (lab(:,:,2) - abmin) ./ (abmax-abmin);
lab(:,:,3) = (lab(:,:,3) - abmin) ./ (abmax-abmin);
lab(:,:,2) = max(0,min(1,lab(:,:,2)));
lab(:,:,3) = max(0,min(1,lab(:,:,3)));
% compute cg from LAB values
cg = zeros([size(im) norient]);
for i = 1:3,
cmap = max(1,ceil(lab(:,:,i)*nbins(i)));
csim = colorsim(nbins(i),sigmaSim(i));
[cg(:,:,i,:),theta] = tgmo(...
cmap,nbins(i),radius(i),norient,...
'tsim',csim,'smooth',smooth,'sigma',sigmaSmo(i));
end
end
% compute color similarity matrix assuming colors are in [0,1]
function m = colorsim(nbins,sigma)
bc = ((1:nbins)-0.5)/nbins; % bin centers
[x,y] = meshgrid(bc,bc);
m = 1.0 - exp(-abs(x-y).^2./(2*sigma.^2));
没有合适的资源?快使用搜索试试~ 我知道了~
图像边缘提取
共24个文件
m:13个
mat:10个
m~:1个
1星 需积分: 10 34 下载量 193 浏览量
2016-01-22
21:09:22
上传
评论
收藏 1.81MB ZIP 举报
温馨提示
Learning to Detect Natural Image Boundaries Using Local Brightness, Color,and Texture Cues 论文的matlab代码,里面pb_demo是主函数
资源推荐
资源详情
资源评论
收起资源包目录
edge.zip (24个子文件)
edge
tgmo.m 2KB
mat
55_pb.mat 67KB
0_0_77_pb.mat 215KB
14037_pb.mat 179KB
299091_pb.mat 212KB
24063_pb.mat 153KB
53_pb.mat 75KB
unitex_6_1_2_1.4_2_128.mat 572KB
demo_pb.m 649B
savgol.m 2KB
assignTextons.m 301B
padReflect.m 839B
pb_299091.mat 68KB
fbRun.m 735B
tgso.m 3KB
pbCGTG.m 2KB
fitparab.m 2KB
cgmo.m 4KB
unitex_6_1_2_1.4_2_32.mat 157KB
nonmax.m 3KB
detCGTG.m 943B
distSqr.m 787B
unitex_6_1_2_1.4_2_64.mat 247KB
demo_pb.m~ 188B
共 24 条
- 1
资源评论
- cflnnugrhp2017-04-20不能运行。。。。。。。
SH-ZZB
- 粉丝: 94
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Python 版冒泡排序算法源代码
- tensorflow-gpu-2.7.2-cp38-cp38-manylinux2010-x86-64.whl
- tensorflow-2.7.3-cp39-cp39-manylinux2010-x86-64.whl
- tensorflow-2.7.2-cp39-cp39-manylinux2010-x86-64.whl
- Python版本快速排序源代码
- Python 语言版的快速排序算法实现
- 450815388207377安卓_base.apk
- 超微主板 X9DRE-TF+ bios 支持 nvme启动
- 基于Python通过下载气象数据和插值拟合离散数据曲线实现对寒潮过程的能量分析
- 智能车仿真软件.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功