Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何从;“装订盒”;[MATLAB]_Matlab_Image Processing_Feature Extraction - Fatal编程技术网

如何从;“装订盒”;[MATLAB]

如何从;“装订盒”;[MATLAB],matlab,image-processing,feature-extraction,Matlab,Image Processing,Feature Extraction,我正在开发粮食质量识别MATLAB应用程序。我对图像进行了预处理,现在我在特征提取阶段遇到了问题 这里是我想从“绑定框”中提取的形态特征和颜色特征 形态特征 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

我正在开发粮食质量识别MATLAB应用程序。我对图像进行了预处理,现在我在特征提取阶段遇到了问题

这里是我想从“绑定框”中提取的形态特征和颜色特征

形态特征

 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
我只想从bound box中提取以上7个功能,我真的很欣赏我为上述目的或任何资源所遵循的方式

谢谢你抽出时间

(1)面积:简单地将边界框内的所有白色像素相加。(2) ,(3)长轴和短轴长度可分别通过边界框的宽度和高度的最大值和最小值找到。(4) 纵横比:边界框的最大(宽度/高度)和(高度/宽度)。(5) ,(6),(7):红色、绿色和蓝色通道的平均值是不言自明的。只需在边界框内分解每个通道,并找到每个通道的平均值。