如何从"边界框中提取形态特征和颜色特征" [MATLAB]

时间:2014-06-14 06:59:16

标签: matlab image-processing feature-extraction

我正在开发谷物质量鉴定MATLAB应用。我预处理了图像,现在我在特征提取阶段遇到了问题,

这些是我想从" bound-box"中提取的形态特征和颜色特征。

形态特征

 1. Area for each Object

 2. Major Axis Length of each bound box

 3. Minor Axis Length of each bound box

 4. Aspect Ratio

颜色特征

1. Red Mean 
2. Green Mean
3. Blue Mean

这是我现在编码的内容

% Get the orginal image & show 
[fileName, pathName] = uigetfile('*.jpg;*.tif;*.png;*.gif','Select the Picture file');
I = fullfile(pathName, fileName);
I = imread(I);
% imshow(I)


% selected rice image Background subtraction 
% Use Morphological Opening to Estimate the Background
background = imopen(I,strel('disk',7));
I2 = I - background;
% figure, imshow(I2);

% get the Black and white Image 
% output image BW replaces all pixels in the input image with luminance greater than 0.17 level 
BW = im2bw(I2,0.15);
% figure, imshow(BW)

% Remove small objects fewer than 30 pixels from binary image
 pure = bwareaopen(BW,30);
% figure, imshow(pure)


% Visualize the individual objects
% figure, imshow(out)
% cc = bwconncomp(out)

% Blobs analysis , This cell of codes find all the objects on the image, and find the properties of each object. 
[Ilabel num] = bwlabel(pure); 
disp(num); 
Iprops = regionprops(Ilabel); 
Ibox = [Iprops.BoundingBox]; 
Ibox = reshape(Ibox,[4 num]); 
imshow(I) 

% Plot the Object Location ,This cell of codes plot the object locations. 
hold on; 
for cnt = 1:num 
rectangle('position',Ibox(:,cnt),'edgecolor','r'); 
end

我只想从绑定框中提取上述7个功能,我非常感谢我为上述目的或任何资源所遵循的方式。

感谢您的时间!

0 个答案:

没有答案