how can i convert RGB to HSV and LAB in this code?

5 views (last 30 days)
function [H] = MethodMTCD(citRGB, binsR, binsG, binsB, binsTheta)
%%MTCD function
% image = 'D:\Dataset\Corel\346.jpg';
binsTheta = 18;
glcm = 16;
binsR = 4;
binsG = 4;
binsB = 4;
panjangFitur = (binsR*binsG*binsB)+binsTheta+glcm;
% citRGB = 'D:\Project Take Over\CBIR\Dataset\Batik\BatikTest\B2_1.jpg';
% citRGB = imread(image);
R = citRGB(:,:,1);
G = citRGB(:,:,2);
B = citRGB(:,:,3);
% Edge detection Sobel
[ RX, RY ] = SobelEdgeDetection(R);
[ GX, GY ] = SobelEdgeDetection(G);
[ BX, BY ] = SobelEdgeDetection(B);
% |a| dan |b|
a = sqrt( RX.^2 + GX.^2 + BX.^2 );
b = sqrt( RY.^2 + GY.^2 + BY.^2 );
% ab
ab = (RX .* RY) + (GX .* GY) + (BX .* BY);
%%Edge Quantization
[bar, kol] = size(a);
% binsTheta = 18;
theta = zeros(bar,kol);
for i = 1:bar
for j = 1:kol
if (a(i,j) == 0 || b(i,j) == 0)
cosab1= 0;
else
cosab1= ab(i,j)/(a(i,j)*b(i,j));
end
theta1 = acosd(cosab1);
theta(i,j) = floor(theta1 * (binsTheta/180));
if (theta(i,j) >= binsTheta-1)
theta(i,j) = binsTheta-1;
end
end
end
KuantisasiTheta = theta;
%%Color Quantization
% mengkuantisasi R menjadi 4 bins, G menjadi 4 bins dan B menjadi 4 bins
% setelah mengkuantisasi, selanjutnya kuantisasi 3 kanal tersebut di gabung
% menjadi 1
% binsR = 4;
KuantisasiR = kuantisasi(binsR, R,255);
% binsG = 4;
KuantisasiG = kuantisasi(binsG, G,255);
% binsB = 4;
KuantisasiB = kuantisasi(binsB, B,255);
KuantisasiColor = (binsB*binsG*KuantisasiR)+(binsB+KuantisasiG) + KuantisasiB;
maxKuantisasi = binsR*binsG*binsB;
%%texton detection
%%feature representation
%MTCD
[H, HH, HV, HLD, HRD, HHB, HVR] = FeatureRepMTCD(KuantisasiColor, KuantisasiTheta, ...
maxKuantisasi, binsTheta );
end

Answers (1)

Image Analyst
Image Analyst on 2 Jun 2015
Simply use the functions rgb2hsv() and rgb2lab():
labImage = rgb2lab(rgbImage);
hsvImage = rgb2hsv(rgbImage);

Categories

Find more on Image Processing Toolbox in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!