%% Colour Segmentation - VIBGYOR Colour Segmentation
%% This function can be used for VIBGYOR Colour segmentation from the RGB
%% Color images.
%% Function C = VIBGYORsegmentation(img)
%% input img = Color image (The input image should be a color image)
%% Example: C = VIBGYORsegmentation(img);
%% Posted date : 14 - 07 - 2008
%%
%% Developed By : K.Kannan & Jeny Rajan
%% Medical Imaging Research Group (MIRG), NeST, Trivandrum.
%%
function C = VIBGYORsegmentation(img)
%% Electro-Magnetic wavelengths ranges in Nano Meter
% red 760-720
% orange 620-590
% yellow 590-545
% green 525-490
% blue 490-450
% indigo 450-420
% violet 420-380
%%
img = imread('E:\5.jpg');
[row col plane] = size(img);
img = double(img);
C = zeros(row,col,plane);
if plane ~= 3
disp('Input should be a color image');
return;
end
GL = 255;
%% Color Choice
clc;
disp(' ');
disp(' r / R - for Red Color');
disp(' o / O - for Orange Color');
disp(' y / Y - for Yellow Color');
disp(' g / G - for Green Color');
disp(' b / B - for Blue Color');
disp(' i / I - for Indigo Color');
disp(' v / V - for Violet Color');
color = input('\nYour Color Choice = ','s');
%%
switch color
case {'R','r'}
f1 = (GL * 1);f2 = (GL * 0.4);f3 = (GL * 0.5);
f4 = (GL * 0);f5 = (GL * 0.5);f6 = (GL * 0);
C = cfilter(img,f1,f2,f3,f4,f5,f6,1,0);
case {'O','o'}
f1 = (GL * 1);f2 = (GL * 0.6);f3 = (GL * 0.68);
f4 = (GL * 0.3);f5 = (GL * 0.3);f6 = (GL * 0);
C = cfilter(img,f1,f2,f3,f4,f5,f6,1,0);
case {'Y','y'}
f1 = (GL * 1);f2 = (GL * 0.78);f3 = (GL * 1);
f4 = (GL * 0.72);f5 = (GL * 0.52);f6 = (GL * 0);
C = cfilter(img,f1,f2,f3,f4,f5,f6,1,1);
case {'G','g'}
f1 = (GL * 0.68);f2 = (GL * 0);f3 = (GL * 1);
f4 = (GL * 0.4);f5 = (GL * 0.68);f6 = (GL * 0);
C = cfilter(img,f1,f2,f3,f4,f5,f6,2,0);
case {'B','b'}
f1 = (GL * 0.5);f2 = (GL * 0);f3 = (GL * 0.68);
f4 = (GL * 0);f5 = (GL * 1);f6 = (GL * 0.4);
C = cfilter(img,f1,f2,f3,f4,f5,f6,3,0);
case {'I','i'}
f1 = (GL * 0.68);f2 = (GL * 0);f3 = (GL * 1);
f4 = (GL * 0.6);f5 = (GL * 1);f6 = (GL * 0.6);
C = cfilter(img,f1,f2,f3,f4,f5,f6,1,1);
case {'V','v'}
f1 = (GL * 1);f2 = (GL * 0.6);f3 = (GL * 0.68);
f4 = (GL * 0);f5 = (GL * 1);f6 = (GL * 0.6);
C = cfilter(img,f1,f2,f3,f4,f5,f6,3,1);
otherwise
disp('unknown method');
end
%% Display
C = uint8(C);
figure, subplot(1,2,1),imshow(uint8(img),[]);title('Original Image');
subplot(1,2,2),imshow(uint8(C),[]);title('Color Segmented Image');
%% Function for Color Filter
function C = cfilter(img,f1,f2,f3,f4,f5,f6,m,flg)
[row col plane] = size(img);
C = zeros(row,col,plane);
for i = 1:row
for j = 1:col
if flg == 0
if (img(i,j,1) <= f1 && img(i,j,1) >= f2 && ...
img(i,j,2) <= f3 && img(i,j,2) >= f4 && ...
img(i,j,3) <= f5 && img(i,j,3) >= f6 ...
&& img(i,j,m) == max([img(i,j,1) img(i,j,2) img(i,j,3)]))
C(i,j,1:3) = img(i,j,1:3);
else
C(i,j,1:3) = (img(i,j,1) * 0.3) + (img(i,j,2) * 0.59) + (img(i,j,3) * 0.11);
end
else
if (img(i,j,1) <= f1 && img(i,j,1) >= f2 && ...
img(i,j,2) <= f3 && img(i,j,2) >= f4 && ...
img(i,j,3) <= f5 && img(i,j,3) >= f6)
C(i,j,1:3) = img(i,j,1:3);
else
C(i,j,1:3) = (img(i,j,1) * 0.3) + (img(i,j,2) * 0.59) + (img(i,j,3) * 0.11);
end
end
end
end
%%
没有合适的资源?快使用搜索试试~ 我知道了~
ColorSegmentation.rar_color segmentation_colorvib_colour segment
共6个文件
jpg:4个
txt:1个
m:1个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 61 浏览量
2022-07-14
00:48:27
上传
评论
收藏 244KB RAR 举报
温馨提示
Colour Segmentation - VIBGYOR Colour Segmentation.This function can be used for VIBGYOR Colour segmentation from the RGB Color images.Posted date : 14 - 07 - 2008 Developed By : K.Kannan & Jeny Rajan
资源推荐
资源详情
资源评论
收起资源包目录
ColorSegmentation.rar (6个子文件)
www.pudn.com.txt 218B
VIBGYOR_Color_Segmentation
VIBGYORsegmentation.m 4KB
NetHues.jpg 54KB
HI_RedCrestedCardinal01.jpg 74KB
rainbow-page2.jpg 35KB
colorcube-1_66.jpg 98KB
共 6 条
- 1
资源评论
四散
- 粉丝: 65
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功